-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix joining of fixed-length tuples with mismatching lengths #8333
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
Fix joining of fixed-length tuples with mismatching lengths #8333
Conversation
e4900ba
to
0bc852b
Compare
0bc852b
to
c7b9a46
Compare
Thanks! Looks good. Maybe also add simple data-driven test (in |
e5c1e86
to
5263a51
Compare
I discovered some awkward behavior when attempting to create a sub-subclass of from typing import Tuple, NamedTuple
class NTup1(NamedTuple):
a: bool
class NTup2(NTup1):
b: bool
tup1 = None # type: NTup1
tup2 = None # type: NTup2
tup1 = tup2 # This should be an error, a 2-tuple type is not compatible with 1-tuple
def bla(x: NTup1): ...
bla(tup2) # This should be an error, a 2-tuple type is not compatible with 1-tuple |
Pushed additional tests. Is this what you had in mind? |
5263a51
to
ffded6b
Compare
Rebased after conflicts from merging #8335. |
e1e1333
to
ed011c3
Compare
For example: Tuple[bool, int] + Tuple[bool] becomes Tuple[int, ...] Previously Mypy simply punted and returned `object`. The handling of fixed tuple + variadic tuple will be implemented separately.
ed011c3
to
c2a1971
Compare
Could you file a separate issue about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good now.
Fix joining of fixed-length tuples with mismatching lengths (python#8333)
For example:
Tuple[bool, int] + Tuple[bool]
becomesTuple[int, ...]
Previously Mypy simply punted and returned
object
.This solves part of #4975. The other missing handling of fixed tuple + variadic tuple will be implemented separately, if this PR goes well. :)