We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a NamedTuple as an Enum member, it converts the NamedTuple to an ordinary tuple, preventing the use of named attributes.
Consider the following base example that will be used to highlight the difference of the code under 3.11.0 and 3.11.1:
from typing import NamedTuple from enum import Enum class Desc(NamedTuple): # sample named tuple label: str num: int class Publisher(Enum): # same enum A = Desc(label='bob', num=1) B = Desc(label='jane', num=2)
In 3.11.0, this works fine:
>>> Publisher.A.value.label 'bob'
In 3.11.1, the following error occurs:
>>> Publisher.A.value.label AttributeError Traceback (most recent call last) Cell In[2], line 1 ----> 1 Publishers.A.value.label AttributeError: 'tuple' object has no attribute 'label'
Interestingly, the named tuple works fine by itself:
>>> summer = Desc(label='summer', num=3) >>> summer.num 3
The text was updated successfully, but these errors were encountered:
Duplicate of #100098
Sorry, something went wrong.
It'll be fixed in 3.11.2 (cc. @ethanfurman)
Check the duplicate for possible work-arounds.
No branches or pull requests
Bug report
When using a NamedTuple as an Enum member, it converts the NamedTuple to an ordinary tuple, preventing the use of named attributes.
Consider the following base example that will be used to highlight the difference of the code under 3.11.0 and 3.11.1:
In 3.11.0, this works fine:
In 3.11.1, the following error occurs:
Interestingly, the named tuple works fine by itself:
Your environment
The text was updated successfully, but these errors were encountered: