Skip to content

Commit 2afee12

Browse files
committed
move test
1 parent 295343e commit 2afee12

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

test-data/unit/check-enum.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,3 +2208,23 @@ class Pet(Enum):
22082208
DOG: str = ... # E: Enum members must be left unannotated \
22092209
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
22102210
# E: Incompatible types in assignment (expression has type "ellipsis", variable has type "str")
2211+
2212+
[case testEnumValueWithPlaceholderNodeType]
2213+
# https://github.com/python/mypy/issues/11971
2214+
from enum import Enum
2215+
from typing import Any, Callable, Dict
2216+
class Foo(Enum):
2217+
Bar: Foo = Callable[[str], None] # E: Enum members must be left unannotated \
2218+
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
2219+
# E: Value of type "int" is not indexable
2220+
Baz: Any = Callable[[Dict[str, "Missing"]], None] # E: Enum members must be left unannotated \
2221+
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
2222+
# E: Value of type "int" is not indexable \
2223+
# E: Type application targets a non-generic function or class \
2224+
# E: Name "Missing" is not defined
2225+
2226+
reveal_type(Foo.Bar) # N: Revealed type is "Literal[__main__.Foo.Bar]?"
2227+
reveal_type(Foo.Bar.value) # N: Revealed type is "__main__.Foo"
2228+
reveal_type(Foo.Baz) # N: Revealed type is "Literal[__main__.Foo.Baz]?"
2229+
reveal_type(Foo.Baz.value) # N: Revealed type is "Any"
2230+
[builtins fixtures/tuple.pyi]

test-data/unit/pythoneval.test

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,28 +1596,6 @@ if isinstance(obj, Awaitable):
15961596
_testSpecialTypingProtocols.py:6: note: Revealed type is "Tuple[builtins.int]"
15971597
_testSpecialTypingProtocols.py:8: error: Statement is unreachable
15981598

1599-
[case testEnumValueWithPlaceholderNodeType]
1600-
# https://github.com/python/mypy/issues/11971
1601-
from enum import Enum
1602-
from typing import Any, Callable, Dict
1603-
class Foo(Enum):
1604-
Bar: Foo = Callable[[str], None]
1605-
Baz: Any = Callable[[Dict[str, "Missing"]], None]
1606-
1607-
reveal_type(Foo.Bar)
1608-
reveal_type(Foo.Bar.value) # this should probably not be "Foo" https://typing.readthedocs.io/en/latest/spec/enums.html#member-values
1609-
reveal_type(Foo.Baz)
1610-
reveal_type(Foo.Baz.value)
1611-
[out]
1612-
_testEnumValueWithPlaceholderNodeType.py:5: error: Enum members must be left unannotated
1613-
_testEnumValueWithPlaceholderNodeType.py:5: error: Incompatible types in assignment (expression has type "<typing special form>", variable has type "Foo")
1614-
_testEnumValueWithPlaceholderNodeType.py:6: error: Enum members must be left unannotated
1615-
_testEnumValueWithPlaceholderNodeType.py:6: error: Name "Missing" is not defined
1616-
_testEnumValueWithPlaceholderNodeType.py:8: note: Revealed type is "Literal[_testEnumValueWithPlaceholderNodeType.Foo.Bar]?"
1617-
_testEnumValueWithPlaceholderNodeType.py:9: note: Revealed type is "_testEnumValueWithPlaceholderNodeType.Foo"
1618-
_testEnumValueWithPlaceholderNodeType.py:10: note: Revealed type is "Literal[_testEnumValueWithPlaceholderNodeType.Foo.Baz]?"
1619-
_testEnumValueWithPlaceholderNodeType.py:11: note: Revealed type is "Any"
1620-
16211599
[case testTypeshedRecursiveTypesExample]
16221600
from typing import List, Union
16231601

0 commit comments

Comments
 (0)