Skip to content

incorrect inference of user-defined variadic tuple subtype instances #19106

Description

@jorenham

Instances of user-defined variadic tuples subtypes are inferred incorrectly:

class Shape[*Ts](tuple[*Ts]): ...

reveal_type((42, ))         # tuple[Literal[42]?]
reveal_type(Shape((42, )))  # __main__.Shape[Unpack[builtins.tuple[Never, ...]]]

https://mypy-play.net/?mypy=1.15.0&python=3.13&gist=2e2ba990a2112c97ca8d9d071c559a56

It should instead be inferred as Shape[Literal[42]].

This occurs with both mypy 1.15 and the current master branch.


related: #19093, #19105
ref: #19100 (comment)

Activity

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

    bugmypy got something wrongtopic-pep-646PEP 646 (TypeVarTuple, Unpack)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions