File tree 3 files changed +14
-2
lines changed
3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -2871,7 +2871,7 @@ def analyze_name_lvalue(self,
2871
2871
outer = self .is_global_or_nonlocal (name )
2872
2872
if kind == MDEF and isinstance (self .type , TypeInfo ) and self .type .is_enum :
2873
2873
# Special case: we need to be sure that `Enum` keys are unique.
2874
- if existing :
2874
+ if existing is not None and not isinstance ( existing . node , PlaceholderNode ) :
2875
2875
self .fail ('Attempted to reuse member name "{}" in Enum definition "{}"' .format (
2876
2876
name , self .type .name ,
2877
2877
), lvalue )
Original file line number Diff line number Diff line change @@ -1810,4 +1810,4 @@ reveal_type(A.str.value) # N: Revealed type is "Literal['foo']?"
1810
1810
reveal_type(A.int.value) # N: Revealed type is "Literal[1]?"
1811
1811
reveal_type(A.bool.value) # N: Revealed type is "Literal[False]?"
1812
1812
reveal_type(A.tuple.value) # N: Revealed type is "Tuple[Literal[1]?]"
1813
- [builtins fixtures/tuple.pyi]
1813
+ [builtins fixtures/tuple.pyi]
Original file line number Diff line number Diff line change @@ -1573,3 +1573,15 @@ x: OrderedDict[str, str] = OrderedDict({})
1573
1573
reveal_type(x) # Revealed type is "collections.OrderedDict[builtins.str, builtins.int]"
1574
1574
[out]
1575
1575
_testTypingExtensionsOrderedDictAlias.py:3: note: Revealed type is "collections.OrderedDict[builtins.str, builtins.str]"
1576
+
1577
+ [case testEnumValueWithPlaceholderNodeType]
1578
+ # https://github.com/python/mypy/issues/11971
1579
+ from enum import Enum
1580
+ from typing import Callable, Dict
1581
+ class Foo(Enum):
1582
+ Bar: Foo = Callable[[str], None]
1583
+ Baz: Foo = Callable[[Dict[str, "Missing"]], None]
1584
+ [out]
1585
+ _testEnumValueWithPlaceholderNodeType.py:5: error: Incompatible types in assignment (expression has type "object", variable has type "Foo")
1586
+ _testEnumValueWithPlaceholderNodeType.py:6: error: Incompatible types in assignment (expression has type "object", variable has type "Foo")
1587
+ _testEnumValueWithPlaceholderNodeType.py:6: error: Name "Missing" is not defined
You can’t perform that action at this time.
0 commit comments