[issue44490] PEP 604 Union (int | str) doesn't have __parameters__
ROpdebee
report at bugs.python.org
Sat Jul 3 07:13:17 EDT 2021
ROpdebee <python at ropdeb.ee> added the comment:
It also lacks the __module__ attribute, causing it to be unusable in PEP 593 typing.Annotated types:
from typing import Annotated
x: Annotated[int | str, 'test']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 298, in inner
return cached(*args, **kwds)
File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 1594, in __class_getitem__
return _AnnotatedAlias(origin, metadata)
File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 1520, in __init__
super().__init__(origin, origin)
File "/Users/ruben/.pyenv/versions/3.10.0b3/lib/python3.10/typing.py", line 976, in __init__
self.__module__ = origin.__module__
AttributeError: 'types.Union' object has no attribute '__module__'. Did you mean: '__reduce__'?
----------
nosy: +ROpdebee
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44490>
_______________________________________
More information about the Python-bugs-list
mailing list