Skip to content

Commit

Permalink
move test
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Oct 26, 2024
1 parent 295343e commit 2afee12
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
20 changes: 20 additions & 0 deletions test-data/unit/check-enum.test
Original file line number Diff line number Diff line change
Expand Up @@ -2208,3 +2208,23 @@ class Pet(Enum):
DOG: str = ... # E: Enum members must be left unannotated \
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
# E: Incompatible types in assignment (expression has type "ellipsis", variable has type "str")

[case testEnumValueWithPlaceholderNodeType]
# https://github.com/python/mypy/issues/11971
from enum import Enum
from typing import Any, Callable, Dict
class Foo(Enum):
Bar: Foo = Callable[[str], None] # E: Enum members must be left unannotated \
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
# E: Value of type "int" is not indexable
Baz: Any = Callable[[Dict[str, "Missing"]], None] # E: Enum members must be left unannotated \
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members \
# E: Value of type "int" is not indexable \
# E: Type application targets a non-generic function or class \
# E: Name "Missing" is not defined

reveal_type(Foo.Bar) # N: Revealed type is "Literal[__main__.Foo.Bar]?"
reveal_type(Foo.Bar.value) # N: Revealed type is "__main__.Foo"
reveal_type(Foo.Baz) # N: Revealed type is "Literal[__main__.Foo.Baz]?"
reveal_type(Foo.Baz.value) # N: Revealed type is "Any"
[builtins fixtures/tuple.pyi]
22 changes: 0 additions & 22 deletions test-data/unit/pythoneval.test
Original file line number Diff line number Diff line change
Expand Up @@ -1596,28 +1596,6 @@ if isinstance(obj, Awaitable):
_testSpecialTypingProtocols.py:6: note: Revealed type is "Tuple[builtins.int]"
_testSpecialTypingProtocols.py:8: error: Statement is unreachable

[case testEnumValueWithPlaceholderNodeType]
# https://github.com/python/mypy/issues/11971
from enum import Enum
from typing import Any, Callable, Dict
class Foo(Enum):
Bar: Foo = Callable[[str], None]
Baz: Any = Callable[[Dict[str, "Missing"]], None]

reveal_type(Foo.Bar)
reveal_type(Foo.Bar.value) # this should probably not be "Foo" https://typing.readthedocs.io/en/latest/spec/enums.html#member-values
reveal_type(Foo.Baz)
reveal_type(Foo.Baz.value)
[out]
_testEnumValueWithPlaceholderNodeType.py:5: error: Enum members must be left unannotated
_testEnumValueWithPlaceholderNodeType.py:5: error: Incompatible types in assignment (expression has type "<typing special form>", variable has type "Foo")
_testEnumValueWithPlaceholderNodeType.py:6: error: Enum members must be left unannotated
_testEnumValueWithPlaceholderNodeType.py:6: error: Name "Missing" is not defined
_testEnumValueWithPlaceholderNodeType.py:8: note: Revealed type is "Literal[_testEnumValueWithPlaceholderNodeType.Foo.Bar]?"
_testEnumValueWithPlaceholderNodeType.py:9: note: Revealed type is "_testEnumValueWithPlaceholderNodeType.Foo"
_testEnumValueWithPlaceholderNodeType.py:10: note: Revealed type is "Literal[_testEnumValueWithPlaceholderNodeType.Foo.Baz]?"
_testEnumValueWithPlaceholderNodeType.py:11: note: Revealed type is "Any"

[case testTypeshedRecursiveTypesExample]
from typing import List, Union

Expand Down

0 comments on commit 2afee12

Please sign in to comment.