-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't workingspec compliance
Description
Describe the bug
There seems to be an unaccounted edge case for capturing callable with default args with TypeVarTuples if both the function and the caller use TypeVars.
Similar to #3775 which was implemented in #6613.
test.py:23:5 - error: Argument of type "*tuple[T@caller, T@caller]" cannot be assigned to parameter "args" of type "*Ts@run_callback" in function "run_callback"
Type "*tuple[T@caller, T@caller]" cannot be assigned to type "*tuple[T@func, T@func, int | None]"
"*tuple[T@caller, T@caller]" is incompatible with "*tuple[T@func, T@func, int | None]"
Tuple size mismatch; expected 3 but received 2 (reportArgumentType)
Code or Screenshots
from collections.abc import Callable
from typing import TypeVar, TypeVarTuple
T = TypeVar("T")
Ts = TypeVarTuple("Ts")
def func(
x: T,
y: T,
z: int | None = None,
) -> None: ...
def run_callback(callback: Callable[[*Ts], None], *args: *Ts) -> None:
# ...
callback(*args)
# ---
def caller(
x: T,
y: T,
) -> None:
run_callback(func, x, y) # Error: Tuple size mismatchThis should be fine. The error disappears if T is replaced with e.g. int.
VS Code extension or command-line
pyright 1.1.348
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't workingspec compliance