Support variadic tuple packing/unpacking#16205
Merged
ilevkivskyi merged 10 commits intopython:masterfrom Oct 8, 2023
Merged
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: kornia (https://github.com/kornia/kornia)
+ kornia/feature/loftr/utils/coarse_matching.py:238: error: Unused "type: ignore" comment [unused-ignore]
spark (https://github.com/apache/spark)
+ python/pyspark/pandas/typedef/typehints.py:783: error: Unused "type: ignore[has-type]" comment [unused-ignore]
|
hauntsaninja
approved these changes
Oct 4, 2023
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is includes also related things such as tuple concatenation, special-cased tuple "re-packing", and star tuple unpacking in homogeneous collections.
It looks like we are very close to the finish line (the only major missing feature is type narrowing using
len(), apart from this I just need to do couple technical things, and make one final search for missed code paths).Some notes:
list[object]is the best type we can have.(x, *y, z), whereyis saytuple[int, ...]. This may cause errors for code that previously worked (when we will turn this feature on). For example(1, *[], 2)[42]will be an error. As usual, I propose to try to be strict, and relax if people will complain (FWIW, I expect very few false positives from this).Unpackcan now "leak" if it was never used explicitly. This is not the case, it is just that experimental features are enabled in tests.Any-like l.h.s types after an error in tuple unpacking (when needed) to avoid extra "Cannot determine type" errors in my tests.@mehdigmira If you are still not tired doing this, please check this PR as usual.