Skip to content

Methods of a variadic generic class become uncallable when specified with TypeVarTuple and a suffix #10845

Open

Description

@96-LB

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.

class Foo[*Ts]:
    def foo(self, *args: *Ts):
        ...

def bar[*Ts, X](foo: Foo[*Ts, X], x: X, *args: *Ts):
    foo.foo(*args, x) # error: Argument missing for parameter "__p2" (reportCallIssue)

Here are some similar constructs which do not trigger this error:

class Foo[*Ts]:
    def foo(self, *args: *Ts):
        ...

# swapping order of generic parameters to Foo
def bar[*Ts, X](foo: Foo[X, *Ts], x: X, *args: *Ts):
    foo.foo(x, *args) # ok
from typing import Callable

# using a callable directly
def bar[*Ts, X](foo: Callable[[*Ts, X], None], x: X, *args: *Ts):
    foo(*args, x) # ok
from typing import Callable

# using an attribute which returns a function instead of a method definition
class Foo[*Ts]:
    def __init__(self, foo: Callable[[*Ts], None]):
        self.foo = foo

def bar[*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.

from typing import Callable

class Foo[*Ts]:
    def __init__(self, foo: Callable[[*Ts], None]):
        self.foo = foo # ok
    
    def foo(self, *args: *Ts):
        ...

def bar[*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
  • This Pyright Playground

Activity

  1. added
    bug
    on Aug 25, 2025
  2. bolu61 commented on Nov 5, 2025

    @bolu61

    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
    
  3. 96-LB commented on Oct 21, 2026

    @96-LB
    Author

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions