Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move test to py312
  • Loading branch information
hamdanal committed Feb 21, 2024
commit 994fbb979eb60f482879311b7cd688e39bef1e74
22 changes: 22 additions & 0 deletions test-data/unit/check-python312.test
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,25 @@ def func2[**P](x: Callable[P, int]) -> Callable[P, str]: ... # E: PEP 695 gener
def func3[*Ts](x: tuple[*Ts]) -> tuple[int, *Ts]: ... # E: PEP 695 generics are not yet supported \
# E: Name "Ts" is not defined
[builtins fixtures/tuple.pyi]

[case test695TypeAliasType]
from typing import Callable, TypeAliasType, TypeVar, TypeVarTuple

T = TypeVar("T")
Ts = TypeVarTuple("Ts")

TestType = TypeAliasType("TestType", int | str)
x: TestType = 42
y: TestType = 'a'
z: TestType = object() # E: Incompatible types in assignment (expression has type "object", variable has type "Union[int, str]")

BadAlias1 = TypeAliasType("BadAlias1", tuple[*Ts]) # E: TypeVarTuple "Ts" is not included in type_params
ba1: BadAlias1[int] # E: Bad number of arguments for type alias, expected 0, given 1
reveal_type(ba1) # N: Revealed type is "builtins.tuple[Any, ...]"

BadAlias2 = TypeAliasType("BadAlias2", Callable[[*Ts], str]) # E: Type variable "Ts" is not included in type_params
ba2: BadAlias2[int] # E: Bad number of arguments for type alias, expected 0, given 1
reveal_type(ba2) # N: Revealed type is "Any"

[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
23 changes: 0 additions & 23 deletions test-data/unit/check-type-aliases.test
Original file line number Diff line number Diff line change
Expand Up @@ -1191,29 +1191,6 @@ reveal_type(unbound_tvt_alias2) # N: Revealed type is "Any"

[builtins fixtures/dict.pyi]

[case testTypeAliasType312]
# flags: --python-version 3.12
from typing import Callable, TypeAliasType, TypeVar, TypeVarTuple

T = TypeVar("T")
Ts = TypeVarTuple("Ts")

TestType = TypeAliasType("TestType", int | str)
x: TestType = 42
y: TestType = 'a'
z: TestType = object() # E: Incompatible types in assignment (expression has type "object", variable has type "Union[int, str]")

BadAlias1 = TypeAliasType("BadAlias1", tuple[*Ts]) # E: TypeVarTuple "Ts" is not included in type_params
ba1: BadAlias1[int] # E: Bad number of arguments for type alias, expected 0, given 1
reveal_type(ba1) # N: Revealed type is "builtins.tuple[Any, ...]"

BadAlias2 = TypeAliasType("BadAlias2", Callable[[*Ts], str]) # E: Type variable "Ts" is not included in type_params
ba2: BadAlias2[int] # E: Bad number of arguments for type alias, expected 0, given 1
reveal_type(ba2) # N: Revealed type is "Any"

[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]

[case testTypeAliasTypeNoUnpackInTypeParams311]
# flags: --python-version 3.11
from typing_extensions import TypeAliasType, TypeVar, TypeVarTuple, Unpack
Expand Down