Skip to content

Can't assign tuple containing a type + a TypeVarTuple to bare tuple #7129

@kltws

Description

@kltws

A tuple of one type + a TypeVarTuple can't be assigned to a bare tuple:
(In Pyright Playground)

def accepts_any_tuple(t: tuple):
    ...

def test[*_Ts](t: tuple[int, *_Ts]):
    accepts_any_tuple(t)

Argument of type "tuple[int, *_Ts@test]" cannot be assigned to parameter "t" of type "tuple[Unknown, ...]" in function "accepts_any_tuple"
  "tuple[int, *_Ts@test]" is incompatible with "tuple[Unknown, ...]"
    Tuple size mismatch; expected 1 but received 2

It looks like the tuple is inferred to have size 2 for some reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions