Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enum does not work if member is an instance of types.GenericAlias #93847

Closed
Assignees
ethanfurman
Labels
3.11only security fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error
@serhiy-storchaka

Description

@serhiy-storchaka

Enums does not work with generic alias of builtin types, likelist[int].

>>> class E(enum.Enum):...     L = list[int]... >>> E.LTraceback (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 withtyping.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 fixes3.12only security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp