Type inference when unpacking tuple #5770
Unanswered
mehdigmira
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Yes, the |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
When unpacking a tuple such as
Pyright (and mypy) seem to be able to infer that x is of type str and y is of type int. How is that achieved ? Since tuple.iter doesn't have a special signature that would allow this inference, is there some special casing in the type checker's code ?
Moreover, the definition of tuple in typeshed stubs seems to only be generic of _T_co which seems a bit weird ? How wome this doesn't cause any problem ? Maybe tuple implementation is hardcoded in each typechecker's logic ? If so can you point out to code lines that implement this ?
Beta Was this translation helpful? Give feedback.
All reactions