-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Enums does not work with generic alias of builtin types, like list[int]
.
>>> class E(enum.Enum):
... L = list[int]
...
>>> E.L
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/enum.py", line 1241, in __repr__
return "<%s.%s: %s>" % (self.__class__.__name__, self._name_, v_repr(self._value_))
^^^^^^^^^^^^^^^^^^^^
TypeError: descriptor '__repr__' requires a 'type' object but received a 'types.GenericAlias'
All works with typing.List[int]
.
>>> class E(enum.Enum):
... L = List[int]
...
>>> E.L
<E.L: typing.List[int]>
This is a manifestation of the #89828 bug.
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibPython modules in the Lib dirPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error