Closed
Description
Describe the bug
error: Argument of type "*tuple[int]" cannot be assigned to parameter "args"
of type "*Ts@run_callback" in function "run_callback"
Type "*tuple[int]" cannot be assigned to type "*tuple[int, str]"
Element size mismatch; expected 2 but received 1
To Reproduce
from typing import Callable
from typing_extensions import Unpack, TypeVarTuple
Ts = TypeVarTuple("Ts")
def func(x: int, y: str = "Hello") -> None: ...
def run_callback(callback: Callable[[Unpack[Ts]], None], *args: Unpack[Ts]) -> None:
# ...
callback(*args)
run_callback(func, 3) # error
Expected behavior
run_callback(func, 3)
should be valid since y
has a default argument.
VS Code extension or command-line
1.1.264
Additional context
For reference the relevant PEP section: https://peps.python.org/pep-0646/#type-variable-tuples-with-callable
However, AFAICT the specific interaction with default arguments in Callables isn't mentioned.