@@ -1604,3 +1604,52 @@ reveal_type(t[i]) # N: Revealed type is "builtins.int"
16041604t1: Tuple[int, Unpack[Tuple[int, ...]]]
16051605reveal_type(t1[i]) # N: Revealed type is "builtins.int"
16061606[builtins fixtures/tuple.pyi]
1607+
1608+ [case testTypeVarTupleNotConcreteCallable]
1609+ from typing_extensions import Unpack, TypeVarTuple
1610+ from typing import Callable, TypeVar, Tuple
1611+
1612+ T = TypeVar("T")
1613+ Args = TypeVarTuple("Args")
1614+ Args2 = TypeVarTuple("Args2")
1615+
1616+ def submit(fn: Callable[[Unpack[Args]], T], *args: Unpack[Args]) -> T:
1617+ ...
1618+
1619+ def submit2(fn: Callable[[int, Unpack[Args]], T], *args: Unpack[Tuple[int, Unpack[Args]]]) -> T:
1620+ ...
1621+
1622+ def foo(func: Callable[[Unpack[Args]], T], *args: Unpack[Args]) -> T:
1623+ return submit(func, *args)
1624+
1625+ def foo2(func: Callable[[Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
1626+ return submit(func, *args)
1627+
1628+ def foo3(func: Callable[[int, Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
1629+ return submit2(func, 1, *args)
1630+
1631+ def foo_bad(func: Callable[[Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
1632+ return submit2(func, 1, *args) # E: Argument 1 to "submit2" has incompatible type "Callable[[VarArg(Unpack[Args2])], T]"; expected "Callable[[int, VarArg(Unpack[Args2])], T]"
1633+ [builtins fixtures/tuple.pyi]
1634+
1635+ [case testTypeVarTupleParamSpecInteraction]
1636+ from typing_extensions import Unpack, TypeVarTuple, ParamSpec
1637+ from typing import Callable, TypeVar
1638+
1639+ T = TypeVar("T")
1640+ Args = TypeVarTuple("Args")
1641+ Args2 = TypeVarTuple("Args2")
1642+ P = ParamSpec("P")
1643+
1644+ def submit(fn: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
1645+ ...
1646+
1647+ def foo(func: Callable[[Unpack[Args]], T], *args: Unpack[Args]) -> T:
1648+ return submit(func, *args)
1649+
1650+ def foo2(func: Callable[[Unpack[Args]], T], *args: Unpack[Args2]) -> T:
1651+ return submit(func, *args) # E: Argument 2 to "submit" has incompatible type "*Tuple[Unpack[Args2]]"; expected "Unpack[Args]"
1652+
1653+ def foo3(func: Callable[[int, Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
1654+ return submit(func, 1, *args)
1655+ [builtins fixtures/tuple.pyi]
0 commit comments