Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.2k
Description
I had a question regarding changes in subclassingEnum
in 3.11. As of 3.11, if enum class has a mixin parent apart fromEnum
which has defined__init__
or__new__
,member._value_
is set to be another instance of the mixin class
unless user defines__new__
in the enum class and set_value_
. However user naturally expects_value_
to be the value assigned to the member in class definition. In the example below
classmixin:def__init__(self):passclassCustomEnum(mixin,Enum):MEMBER="member"
CustomEnum.MEMBER
is an instance of mixin andCustomEnum.MEMBER.value
is another instance of it (with different id), while it was expected thatCustomEnum.MEMBER.value
would be"member"
. What has been the rationale for this change?
By the way, this change is not noted in python docs enumeration page.