[issue42233] GenericAlias does not support union type expressions

2021-11-21 Thread Dávid Nemeskey

Dávid Nemeskey  added the comment:

@kj Sorry, for some reason, I thought the that issue affected Union as well, 
but I have just re-tested it and found that it works.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2021-11-19 Thread Ken Jin

Ken Jin  added the comment:

@Dávid

No it won't land in 3.9. Union type expressions (PEP 604) were only officially 
added in 3.10. We don't backport new features, only bugfixes. Sorry!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2021-11-19 Thread Dávid Nemeskey

Dávid Nemeskey  added the comment:

Guys, any chance the fix will land in 3.9? It is affected as well.

--
nosy: +nemeskeyd

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-08 Thread Ken Jin


Change by Ken Jin :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-08 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 4eb41d055e8307b8206f680287e492a6db068acd by kj in branch 'master':
bpo-42233: Add union type expression support for GenericAlias and fix 
de-duplicating of GenericAlias (GH-23077)
https://github.com/python/cpython/commit/4eb41d055e8307b8206f680287e492a6db068acd


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-07 Thread miss-islington


miss-islington  added the comment:


New changeset e81e09bfc8a29a44a649a962870a26fe0c097cfa by Miss Islington (bot) 
in branch '3.9':
bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)
https://github.com/python/cpython/commit/e81e09bfc8a29a44a649a962870a26fe0c097cfa


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread miss-islington


Change by miss-islington :


--
pull_requests: +22000
pull_request: https://github.com/python/cpython/pull/23082

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread miss-islington


miss-islington  added the comment:


New changeset 1f7dfb277e5b88cddc13e5024766be787a3e9127 by kj in branch 'master':
bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)
https://github.com/python/cpython/commit/1f7dfb277e5b88cddc13e5024766be787a3e9127


--
nosy: +miss-islington

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin


Change by Ken Jin :


--
pull_requests: +21999
pull_request: https://github.com/python/cpython/pull/23081

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin


Ken Jin  added the comment:

@Serhiy, wow interesting find, it seems to be typing's repr problem rather than 
the actual types itself:

>>> typing.Union[dict[int, str], list[str]]
typing.Union[dict, list]

>>> typing.Union[dict[int, str], list[str]].__args__
(dict[int, str], list[str])

The __args__ seem to be correct, so I'm guessing the typing repr went wrong 
somewhere. That should be the case for your example too:

>>> alias = typing.List[int] | dict[float, str]
>>> alias
typing.Union[typing.List[int], dict]

>>> type(alias)


>>> alias.__args__
(typing.List[int], dict[float, str])

I'll work on this. If I don't reply back in a week, someone else is free to 
take over this issue.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is also a problem with typing module.

>>> typing.List[int] | dict[float, str]
typing.Union[typing.List[int], dict]

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
pull_requests: +21997
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/23077

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42233] GenericAlias does not support union type expressions

2020-11-01 Thread Ken Jin


New submission from Ken Jin :

Union type expressions added in PEP 604 throw an error when both operands are 
GenericAlias objects.

Eg the following works::

int | list[str]

The following throws TypeError::

list[int] | dict[float, str]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 
'types.GenericAlias'

I have submitted a PR to fix this. Coincidentally, it also fixes the fact that 
union expressions weren't de-duplicating GenericAlias properly.

Eg::
>>> list[int] | int | list[int]
list[int] | int | list[int]

For non-GenericAlias type expressions, the new code shouldn't be much slower. 
Rich compare is only used for GenericAlias objects. This isn't very scientific, 
but 

python -m timeit "int | str | float"

# original
100 loops, best of 5: 295 nsec per loop

# purely rich compare
100 loops, best of 5: 344 nsec per loop

# check  for GenericAlias and rich compare only for that
100 loops, best of 5: 297 nsec per loop

--
components: Interpreter Core
messages: 380145
nosy: gvanrossum, kj, levkivskyi
priority: normal
severity: normal
status: open
title: GenericAlias does not support union type expressions
versions: Python 3.10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com