Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jorenham opened this issue May 18, 2025 · 0 comments
Open

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

jorenham opened this issue May 18, 2025 · 0 comments
Labels
bug mypy got something wrong topic-pep-646 PEP 646 (TypeVarTuple, Unpack)

Comments

@jorenham
Copy link
Contributor

jorenham commented May 18, 2025

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)

@jorenham jorenham added the bug mypy got something wrong label May 18, 2025
@sterliakov sterliakov added the topic-pep-646 PEP 646 (TypeVarTuple, Unpack) label May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-646 PEP 646 (TypeVarTuple, Unpack)
Projects
None yet
Development

No branches or pull requests

2 participants