Skip to content

Commit cabdf50

Browse files
committed
Some more testing
1 parent d0760b1 commit cabdf50

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test-data/unit/check-typevar-defaults.test

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ T3 = TypeVar("T3", bound=List[Any], default=List[int])
4141
T4 = TypeVar("T4", int, str, default=int)
4242
T5 = TypeVar("T5", default=S0)
4343
T6 = TypeVar("T6", bound=float, default=S1)
44-
# T7 = TypeVar("T7", bound=List[Any], default=List[S0]) # TODO
44+
T7 = TypeVar("T7", bound=List[Any], default=List[S0])
4545

4646
P1 = ParamSpec("P1", default=[])
4747
P2 = ParamSpec("P2", default=...)
@@ -50,7 +50,7 @@ P4 = ParamSpec("P4", default=P0)
5050

5151
Ts1 = TypeVarTuple("Ts1", default=Unpack[Tuple[int]])
5252
Ts2 = TypeVarTuple("Ts2", default=Unpack[Tuple[int, ...]])
53-
# Ts3 = TypeVarTuple("Ts3", default=Unpack[Ts0]) # TODO
53+
Ts3 = TypeVarTuple("Ts3", default=Unpack[Ts0])
5454
[builtins fixtures/tuple.pyi]
5555

5656
[case testTypeVarDefaultsInvalid]
@@ -180,7 +180,7 @@ reveal_type(func_b1(callback1)) # N: Revealed type is "def (x: builtins.str)"
180180
reveal_type(func_b1(2)) # N: Revealed type is "def (builtins.int, builtins.str)"
181181

182182
def func_c1(x: Union[int, Callable[[Unpack[Ts1]], None]]) -> Tuple[Unpack[Ts1]]: ...
183-
# reveal_type(func_c1(callback1)) # Revealed type is "Tuple[str]" # TODO
183+
reveal_type(func_c1(callback1)) # N: Revealed type is "tuple[builtins.str]"
184184
reveal_type(func_c1(2)) # N: Revealed type is "tuple[builtins.int, builtins.str]"
185185
[builtins fixtures/tuple.pyi]
186186

@@ -894,6 +894,20 @@ Alias: TypeAlias = "MyClass[T1, T2]"
894894
class MyClass(Generic["T1", "T2"]): ...
895895
[builtins fixtures/tuple.pyi]
896896

897+
[case testDefaultsApplicationInAliasNoCrashNested]
898+
from typing import Generic, TypeVar
899+
from typing_extensions import TypeAlias
900+
901+
T1 = TypeVar("T1")
902+
T2 = TypeVar("T2", default=list[T1])
903+
904+
Alias: TypeAlias = "MyClass[T1, T2]"
905+
906+
class MyClass(Generic["T1", "T2"]): ...
907+
x: Alias[int]
908+
reveal_type(x) # N: Revealed type is "__main__.MyClass[builtins.int, builtins.list[builtins.int]]"
909+
[builtins fixtures/tuple.pyi]
910+
897911
[case testDefaultsMustBeInScope]
898912
from typing import Generic, TypeVar
899913

0 commit comments

Comments
 (0)