Skip to content

reportMatchNotExhaustive on variadic length tuples #11056

@Enegg

Description

@Enegg

Describe the bug
In a match-case statement, a (*args,) capture pattern should match any tuple.
Similarly, (first, *args) and (*args, last) capture patterns should match any tuple with at least one element.

Code or Screenshots

def foo(x: tuple[object, *tuple[object, ...], object]) -> None:
    match x:  # Unhandled type: "tuple[object, *tuple[object, ...], object]"
        case (*args,):
            del args
    match x:  # Unhandled type: "tuple[object, *tuple[object, ...], object]"
        case (*args, last):
            del args, last
    match x:  # ok
        case (first, *args, last):
            del first, args, last

VS Code extension or command-line
Pylance 2025.9.1
Also tested with Pyright 1.1.407 on playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions