Closed as not planned
Description
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:
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
Your environment
- CPython versions tested on: 3.11.0, 3.11.1
- Operating system and architecture: M1