tuple[Literal[1, 2]]
is not assignable to tuple[Literal[1]] | tuple[Literal[2]]
#8271
InSyncWithFoo
started this conversation in
General
Replies: 1 comment
-
This is a known limitation. Pyright does not expand tuples when considering type compatibility. No other Python type checkers do this either. Pyright, unlike other type checkers, does perform limited tuple expansion for purposes of type narrowing in The typing spec was recently updated to indicate that such types are equivalent. It indicates that type checkers may treat them as such for purposes of narrowing tuple types, but it doesn't mandate it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reproducible example (playground):
tuple[]
should distribute over the unionLiteral[1, 2]
/Literal[1] | Literal[2]
, resulting intuple[Literal[1]] | tuple[Literal[2]]
. Is this a bug or a known limitation?Beta Was this translation helpful? Give feedback.
All reactions