GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Enum does not work if member is an instance of types.GenericAlias · Issue #93847 · python/cpython

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

New issue
Copy link
New issue
Copy link
Closed
#93885
Closed
Enum does not work if member is an instance of types.GenericAlias#93847
#93885
Copy link
Assignees
ethanfurman
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@serhiy-storchaka
serhiy-storchaka
opened on Jun 15, 2022
Issue body actions

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.

Activity

  1. serhiy-storchaka
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-typing
    on Jun 15, 2022
  2. serhiy-storchaka
    changed the title [-]Enum does not work if member is an instance oftypes.GenericAlias[/-] [+]Enum does not work if member is an instance of types.GenericAlias[/+] on Jun 15, 2022
  3. kumaraditya303
    assigned
    ethanfurman
    on Jun 15, 2022
  4. AlexWaygood
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on Jun 15, 2022
  5. serhiy-storchaka
    added a commit that references this issue on Jun 16, 2022

    pythongh-93847: Fix repr of enum of generic aliases

    0ecc18f
  6. serhiy-storchaka commented on Jun 16, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Jun 16, 2022
    MemberAuthor
    More actions

    It is not directly caused by the #89828 bug, but both bugs have the same cause (fixed in #93754).

  7. ethanfurman
    closed this as completedin #93885on Jun 16, 2022
  8. ethanfurman
    added a commit that references this issue on Jun 16, 2022

    gh-93847: Fix repr of enum of generic aliases (GH-93885)

    138db8e
  9. miss-islington
    added 2 commits that reference this issue on Jun 16, 2022

    pythongh-93847: Fix repr of enum of generic aliases (pythonGH-93885)

    50a73f6

    gh-93847: Fix repr of enum of generic aliases (GH-93885)

    0319052
  10. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

    1ffde3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @ethanfurman
    ethanfurman

Labels

3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.