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:
Ethan Furman 2023-04-13 08:31:03 -07:00 committed by GitHub
parent 2194071540
commit a6f95941a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View file

@ -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: