@@ -2407,3 +2407,56 @@ reveal_type(x) # N: Revealed type is "__main__.C[builtins.str, builtins.int]"
24072407reveal_type(C(f)) # N: Revealed type is "__main__.C[builtins.str, builtins.int, builtins.int, builtins.int, builtins.int]"
24082408C[()] # E: At least 1 type argument(s) expected, none given
24092409[builtins fixtures/tuple.pyi]
2410+
2411+ [case testTypeVarTupleAgainstParamSpecActualSuccess]
2412+ from typing import Generic, TypeVar, TypeVarTuple, Unpack, Callable, Tuple, List
2413+ from typing_extensions import ParamSpec
2414+
2415+ R = TypeVar("R")
2416+ P = ParamSpec("P")
2417+
2418+ class CM(Generic[R]): ...
2419+ def cm(fn: Callable[P, R]) -> Callable[P, CM[R]]: ...
2420+
2421+ Ts = TypeVarTuple("Ts")
2422+ @cm
2423+ def test(*args: Unpack[Ts]) -> Tuple[Unpack[Ts]]: ...
2424+
2425+ reveal_type(test) # N: Revealed type is "def [Ts] (*args: Unpack[Ts`-1]) -> __main__.CM[Tuple[Unpack[Ts`-1]]]"
2426+ reveal_type(test(1, 2, 3)) # N: Revealed type is "__main__.CM[Tuple[Literal[1]?, Literal[2]?, Literal[3]?]]"
2427+ [builtins fixtures/tuple.pyi]
2428+
2429+ [case testTypeVarTupleAgainstParamSpecActualFailedNoCrash]
2430+ from typing import Generic, TypeVar, TypeVarTuple, Unpack, Callable, Tuple, List
2431+ from typing_extensions import ParamSpec
2432+
2433+ R = TypeVar("R")
2434+ P = ParamSpec("P")
2435+
2436+ class CM(Generic[R]): ...
2437+ def cm(fn: Callable[P, List[R]]) -> Callable[P, CM[R]]: ...
2438+
2439+ Ts = TypeVarTuple("Ts")
2440+ @cm # E: Argument 1 to "cm" has incompatible type "Callable[[VarArg(Unpack[Ts])], Tuple[Unpack[Ts]]]"; expected "Callable[[VarArg(Never)], List[Never]]"
2441+ def test(*args: Unpack[Ts]) -> Tuple[Unpack[Ts]]: ...
2442+
2443+ reveal_type(test) # N: Revealed type is "def (*args: Never) -> __main__.CM[Never]"
2444+ [builtins fixtures/tuple.pyi]
2445+
2446+ [case testTypeVarTupleAgainstParamSpecActualPrefix]
2447+ from typing import Generic, TypeVar, TypeVarTuple, Unpack, Callable, Tuple, List
2448+ from typing_extensions import ParamSpec, Concatenate
2449+
2450+ R = TypeVar("R")
2451+ P = ParamSpec("P")
2452+ T = TypeVar("T")
2453+
2454+ class CM(Generic[R]): ...
2455+ def cm(fn: Callable[Concatenate[T, P], R]) -> Callable[Concatenate[List[T], P], CM[R]]: ...
2456+
2457+ Ts = TypeVarTuple("Ts")
2458+ @cm
2459+ def test(x: T, *args: Unpack[Ts]) -> Tuple[T, Unpack[Ts]]: ...
2460+
2461+ reveal_type(test) # N: Revealed type is "def [T, Ts] (builtins.list[T`2], *args: Unpack[Ts`-2]) -> __main__.CM[Tuple[T`2, Unpack[Ts`-2]]]"
2462+ [builtins fixtures/tuple.pyi]
0 commit comments