-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[WIP] Fix issue #4975 #8253
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
[WIP] Fix issue #4975 #8253
Conversation
@ilevkivskyi @Michael0x2a appears to be working if I hardcode a file from typing import Tuple
x: Tuple[str, float]
y: Tuple[int, ...]
lst = [x, y]
reveal_type(lst[0]) produces
with no errors. However, running the same in the test suite seems to cause issues. Similar with the following from typing import Tuple
x: Tuple[int, str]
y: Tuple[int, ...]
lst = [x, y]
reveal_type(lst[0]) produces
|
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 for PR!
The tests failed because the list.pyi
test fixture defines tuple
as invariant, you can update it. Alternatively you can use tuple.pyi
fixture.
I don't think this covers all the cases in the original issue and the issues that were closed as duplicates. In particular, these test cases are missing:
- Join two tuples of different length:
Tuple[str, str]
vsTuple[str, str, str]
- Ditto with different types
- Joins with an empty tuple (fixed length and variable length)
- It would be great to have a test with ternary expressions instead of lists.
You can browse through linked issues, maybe there are more.
Sorry, I will not have time for this, hopefully @JukkaL or @msullivan can help. |
I can finish the review. The next steps would be fixing the merge conflict and the failing test cases. If you need help with some of these, just let me know. |
Doh, sorry :( I was under the impression that nobody was working on this issue (made that assumption when JelleZijlstra commented in #4975). It didn't help that this PR is titled "Initial attempt" So meanwhile I submitted two pull requests for the two behaviors implemented here: #8333 and #8335. The good news is that I happened to find a cleaner implementation, my approach can join I now tested my code with the test cases in this PR and my code passes these cases. What do you think is the best way forward? |
@intgr well, you were quick on the uptake, so I don't have a problem if they merge yours instead of mine. In the future, I can title my PR better, but I did reference the issue in this PR and it does show up on the Issue tracker... Nevertheless, taking a quick look at your PR shows that we had approximately the same idea, it's up the maintainers @JukkaL @ilevkivskyi to make the final call. There was an issue with my PR that was raised regarding types that inherit from Tuple: if we go with yours, we might try to fix that too? |
Thanks, for the heads-up, I hadn't considered Tuple subclasses. I'll have to test that behavior. |
Addresses issue #4975. See three test cases, first is passing, unclear on what the behavior should be on second two