-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix: internal error caused by the generic type alias with an unpacked list #20689
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Updated type alias test cases to reflect syntax changes.
This comment has been minimized.
This comment has been minimized.
Update error messages for invalid syntax in type alias tests.
This comment has been minimized.
This comment has been minimized.
Add tests for type alias unpacking with lists.
This comment has been minimized.
This comment has been minimized.
Update type alias tests to reflect unpacking errors for list[int].
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
left a comment
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.
Not a full review, just something for you while you are fixing the tests.
| unpacked = get_proper_type(item.type) | ||
| if isinstance(unpacked, Instance): | ||
| assert unpacked.type.fullname == "builtins.tuple" | ||
| if unpacked.type.fullname != "builtins.tuple": |
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.
Please add a comment above this line explaining that expand_type() may be called during semantic analysis, before invalid unpacks are fixed.
This comment has been minimized.
This comment has been minimized.
Add comment to clarify behavior during semantic analysis.
This comment has been minimized.
This comment has been minimized.
Updated test cases for TypeAlias unpacking in Python.
This comment has been minimized.
This comment has been minimized.
Removed xfail marker from test case and updated comments for clarity.
This comment has been minimized.
This comment has been minimized.
Add test cases for unpacked type aliases in Python 3.10 and 3.11
This comment has been minimized.
This comment has been minimized.
Update error messages for type alias unpacking tests.
This comment has been minimized.
This comment has been minimized.
Update error messages for unpacking list in type alias tests to reflect Python version requirements.
Updated error messages for unpacking list[int] in type alias tests.
This comment has been minimized.
This comment has been minimized.
Updated type alias test cases to reflect syntax changes in Python 3.11.
Updated test cases to reflect unpacking rules for TypeAlias.
This comment has been minimized.
This comment has been minimized.
Update comments to clarify expectations for unpacking lists in type aliases.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
|
||
| # Only "Test suite with py310-ubuntu, mypyc-compiled" expects: Invalid syntax | ||
| # The other tests expect: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple) | ||
| # v1: TA[*list[int]] |
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.
If you want to test the new *-syntax, you should move the test to check-python311.test, then you will not need all these dances with having two separate tests, etc.
Fixes: #20549