mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
gh-103479: [Enum] require __new__ to be considered a data type (GH-103495)
a mixin must either have a __new__ method, or be a dataclass, to be interpreted as a data-type
This commit is contained in:
parent
2194071540
commit
a6f95941a3
3 changed files with 14 additions and 10 deletions
|
@ -967,6 +967,7 @@ class EnumType(type):
|
|||
|
||||
@classmethod
|
||||
def _find_data_type_(mcls, class_name, bases):
|
||||
# a datatype has a __new__ method, or a __dataclass_fields__ attribute
|
||||
data_types = set()
|
||||
base_chain = set()
|
||||
for chain in bases:
|
||||
|
@ -979,7 +980,7 @@ class EnumType(type):
|
|||
if base._member_type_ is not object:
|
||||
data_types.add(base._member_type_)
|
||||
break
|
||||
elif '__new__' in base.__dict__ or '__init__' in base.__dict__:
|
||||
elif '__new__' in base.__dict__ or '__dataclass_fields__' in base.__dict__:
|
||||
data_types.add(candidate or base)
|
||||
break
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue