Skip to content

Commit 2632de8

Browse files
committed
Add *Ts syntax to check-python311.test
1 parent f3a1f13 commit 2632de8

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test-data/unit/check-python311.test

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,55 @@ x4: Alias4[int] # E: Bad number of arguments for type alias, expected 0, given
174174
reveal_type(x4) # N: Revealed type is "def (*Any) -> builtins.int"
175175
[builtins fixtures/tuple.pyi]
176176

177+
[case testVariadicTypedDictDeriveStar]
178+
from typing import Tuple, Callable, Generic, TypedDict, TypeVar
179+
from typing_extensions import TypeVarTuple
180+
181+
T = TypeVar("T")
182+
Ts = TypeVarTuple("Ts")
183+
class A(TypedDict, Generic[*Ts]):
184+
fn: Callable[[*Ts], None]
185+
186+
class B(A[*Ts]):
187+
val: bool
188+
189+
class C(A[*Ts], Generic[*Ts, T]):
190+
val: T
191+
192+
y: B[int, str]
193+
reveal_type(y) # N: Revealed type is "TypedDict('__main__.B', {'fn': def (builtins.int, builtins.str), 'val': builtins.bool})"
194+
reveal_type(y["fn"]) # N: Revealed type is "def (builtins.int, builtins.str)"
195+
reveal_type(y["val"]) # N: Revealed type is "builtins.bool"
196+
197+
y2: C[int, str, bool]
198+
reveal_type(y2) # N: Revealed type is "TypedDict('__main__.C', {'fn': def (builtins.int, builtins.str), 'val': builtins.bool})"
199+
reveal_type(y2["fn"]) # N: Revealed type is "def (builtins.int, builtins.str)"
200+
reveal_type(y2["val"]) # N: Revealed type is "builtins.bool"
201+
202+
z: B[*Tuple[int, ...]]
203+
reveal_type(z) # N: Revealed type is "TypedDict('__main__.B', {'fn': def (*builtins.int), 'val': builtins.bool})"
204+
reveal_type(z["fn"]) # N: Revealed type is "def (*builtins.int)"
205+
reveal_type(y["val"]) # N: Revealed type is "builtins.bool"
206+
207+
z2: C[*Tuple[int, ...]]
208+
reveal_type(z2) # N: Revealed type is "TypedDict('__main__.C', {'fn': def (*builtins.int), 'val': builtins.int})"
209+
reveal_type(z2["fn"]) # N: Revealed type is "def (*builtins.int)"
210+
reveal_type(z2["val"]) # N: Revealed type is "builtins.int"
211+
212+
z3: C[*Tuple[int, ...], bool]
213+
reveal_type(z3) # N: Revealed type is "TypedDict('__main__.C', {'fn': def (*builtins.int), 'val': builtins.bool})"
214+
reveal_type(z3["fn"]) # N: Revealed type is "def (*builtins.int)"
215+
reveal_type(z3["val"]) # N: Revealed type is "builtins.bool"
216+
217+
t: B[int, *Tuple[int, str]]
218+
reveal_type(t) # N: Revealed type is "TypedDict('__main__.B', {'fn': def (builtins.int, builtins.int, builtins.str), 'val': builtins.bool})"
219+
220+
t2: C[int, *Tuple[int, str]]
221+
reveal_type(t2) # N: Revealed type is "TypedDict('__main__.C', {'fn': def (builtins.int, builtins.int), 'val': builtins.str})"
222+
223+
[builtins fixtures/dict.pyi]
224+
[typing fixtures/typing-typeddict.pyi]
225+
177226
[case testReturnInExceptStarBlock1]
178227
# flags: --python-version 3.11
179228
def foo() -> None:

0 commit comments

Comments
 (0)