Closed
Description
I had a question regarding changes in subclassing Enum
in 3.11. As of 3.11, if enum class has a mixin parent apart from Enum
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
class mixin:
def __init__(self):
pass
class CustomEnum(mixin, Enum):
MEMBER = "member"
CustomEnum.MEMBER
is an instance of mixin and CustomEnum.MEMBER.value
is another instance of it (with different id), while it was expected that CustomEnum.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.