Skip to content

Commit da6be94

Browse files
sobolevnJukkaL
authored andcommitted
Fixes regression with __module__ and similar non-final Enum names, refs #11820 (#11823)
1 parent 3773d2d commit da6be94

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

mypy/semanal_enum.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
))
2222
ENUM_SPECIAL_PROPS: Final = frozenset((
2323
'name', 'value', '_name_', '_value_', '_order_', '__order__',
24+
# Also attributes from `object`:
25+
'__module__', '__annotations__', '__doc__', '__slots__', '__dict__',
2426
))
2527

2628

test-data/unit/check-enum.test

+11-1
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,11 @@ class E(Enum):
16891689
_value_ = 'b2'
16901690
_order_ = 'X Y'
16911691
__order__ = 'X Y'
1692+
__slots__ = ()
1693+
__doc__ = 'doc'
1694+
__module__ = 'module'
1695+
__annotations__ = {'a': int}
1696+
__dict__ = {'a': 1}
16921697

16931698
class EI(IntEnum):
16941699
name = 'a'
@@ -1697,10 +1702,15 @@ class EI(IntEnum):
16971702
_value_ = 2
16981703
_order_ = 'X Y'
16991704
__order__ = 'X Y'
1705+
__slots__ = ()
1706+
__doc__ = 'doc'
1707+
__module__ = 'module'
1708+
__annotations__ = {'a': int}
1709+
__dict__ = {'a': 1}
17001710

17011711
E._order_ = 'a' # E: Cannot assign to final attribute "_order_"
17021712
EI.value = 2 # E: Cannot assign to final attribute "value"
1703-
[builtins fixtures/bool.pyi]
1713+
[builtins fixtures/dict.pyi]
17041714

17051715
[case testEnumNotFinalWithMethodsAndUninitializedValues]
17061716
# https://github.com/python/mypy/issues/11578

0 commit comments

Comments
 (0)