You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Methods of a variadic generic class become uncallable when specified with TypeVarTuple and a suffix #10845
When a variadic generic class is indexed with an unpacked TypeVarTuple followed by some suffix, any methods of that class which unpack the variadic generic fail to typecheck regardless of what arguments you pass in. It seems that the variadic args somehow swallow up all following arguments, making it impossible to pass in arguments corresponding to the suffix types.
In the following example, the call to foo.foo is expected to typecheck. However, it instead throws a cryptic error which is unable to be resolved with any set of arguments.
Here are some similar constructs which do not trigger this error:
classFoo[*Ts]:
deffoo(self, *args: *Ts):
...
# swapping order of generic parameters to Foodefbar[*Ts, X](foo: Foo[X, *Ts], x: X, *args: *Ts):
foo.foo(x, *args) # ok
fromtypingimportCallable# using a callable directlydefbar[*Ts, X](foo: Callable[[*Ts, X], None], x: X, *args: *Ts):
foo(*args, x) # ok
fromtypingimportCallable# using an attribute which returns a function instead of a method definitionclassFoo[*Ts]:
def__init__(self, foo: Callable[[*Ts], None]):
self.foo=foodefbar[*Ts, X](foo: Foo[*Ts, X], x: X, *args: *Ts):
foo.foo(*args, x) # ok
Despite the last non-example, it seems the mere presence of a method declaraton causes the error to reappear, even though the revealed type of foo.foo doesn't change.
fromtypingimportCallableclassFoo[*Ts]:
def__init__(self, foo: Callable[[*Ts], None]):
self.foo=foo# okdeffoo(self, *args: *Ts):
...
defbar[*Ts, X](foo: Foo[*Ts, X], x: X, *args: *Ts):
reveal_type(foo.foo) # Type of "foo.foo" is "(*Ts@bar, X@bar) -> None"foo.foo(*args, x) # Argument missing for parameter "__p2"
This issue occurs with:
Command-line version 1.1.404
VS Code Pylance extension release version 2025.7.1
VS Code Pylance extension pre-release version 2025.7.102
Also happens when the problematic method declaration is overriden:
class Foo[*Ts]:
def foo(self, *args: *Ts):
...
class Bar[*Ts, X](Foo[*Ts, X]):
def foo(self, *args: *tuple[*Ts, X]): # Method "foo" overrides class "Foo" in an incompatible manner
... # Parameter "__p2" is missing in override
This issue was closed, but all the false positives provided in the thread still happen on versions 1.1.409 (where PR #11363 was introduced) through 1.1.414 (latest version at the time of this comment). The tests in the linked PR don't cover this issue. Could it be reopened?
Activity
bolu61 commentedon Nov 5, 2025
Also happens when the problematic method declaration is overriden:
96-LB commentedon Oct 21, 2026
This issue was closed, but all the false positives provided in the thread still happen on versions 1.1.409 (where PR #11363 was introduced) through 1.1.414 (latest version at the time of this comment). The tests in the linked PR don't cover this issue. Could it be reopened?