-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Changes from 20 commits
d5c8177
ad423fd
f92844f
bc3db3d
d24ccff
cb768f6
d7b4615
1221422
0c0d582
2676b24
1121925
40cd52d
c4fc5e5
5999e31
8a3c1d0
740cdb1
57535da
d4f0e67
08235af
d66d09d
f921b76
a653243
3c0287e
b5aa88e
f1e2e85
3608ab4
fd82e4f
00c333c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1237,6 +1237,36 @@ Ta2 = TypeAliasType("Ta2", None, type_params=(Unpack[Ts],)) # E: Free type vari | |
|
|
||
| [builtins fixtures/tuple.pyi] | ||
|
|
||
| [case testGenericTypeAliasArgOfTypeAliasIsUnpackedTuple] | ||
| # flags: --python-version 3.11 | ||
| from typing_extensions import TypeAlias | ||
| from typing import TypeVarTuple, Unpack | ||
|
|
||
| Ts = TypeVarTuple('Ts') | ||
| TA: TypeAlias = tuple[Unpack[Ts]] | ||
|
|
||
| # Only "Test suite with py310-ubuntu, mypyc-compiled" expects: Invalid syntax; you likely need to run mypy using Python 3.11 or newer | ||
| # The other tests expect: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple) | ||
| # v1: TA[*list[int]] | ||
|
|
||
| v2: TA[Unpack[list[int]]] # E: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple) | ||
| [builtins fixtures/tuple.pyi] | ||
|
|
||
| [case testGenericTypeAliasArgOfTypeAliasIsUnpackedTuple310] | ||
| # flags: --python-version 3.10 | ||
| from typing_extensions import TypeAlias | ||
| from typing import TypeVarTuple, Unpack | ||
|
|
||
| Ts = TypeVarTuple('Ts') | ||
| TA: TypeAlias = tuple[Unpack[Ts]] | ||
|
|
||
| # 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]] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to test the new
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I cannot write the tests for the code For
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is less tricky if you follow advise precisely :-) |
||
|
|
||
| v2: TA[Unpack[list[int]]] # E: "list[int]" cannot be unpacked (must be tuple or TypeVarTuple) | ||
| [builtins fixtures/tuple.pyi] | ||
|
|
||
| [case testAliasInstanceNameClash] | ||
| from lib import func | ||
| class A: ... | ||
|
|
||
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.