-
-
Notifications
You must be signed in to change notification settings - Fork 109
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 subscription of Unpack causing nested Unpacks to not be resolved correctly #480
Conversation
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, this looks close to ready.
CHANGELOG.md
Outdated
@@ -16,6 +16,8 @@ | |||
subscripted objects) had wrong parameters if they were directly | |||
subscripted with an `Unpack` object. | |||
Patch by [Daraan](https://github.com/Daraan). | |||
- Fix error in subscription of Unpack aliases causing nested Unpacks |
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.
- Fix error in subscription of Unpack aliases causing nested Unpacks | |
- Fix error in subscription of `Unpack` aliases causing nested Unpacks |
src/test_typing_extensions.py
Outdated
def test_substitution(self): | ||
Ts = TypeVarTuple("Ts") | ||
unpacked_str = Unpack[Ts][str] | ||
with self.subTest("Check substitution result"): |
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.
No need for subTest for a single test
src/test_typing_extensions.py
Outdated
|
||
TupleAliasTsT = Variadic[Tuple[Unpack[Ts], T]] | ||
# Equivalent Forms | ||
with self.subTest("Equivalence of variadic arguments"): |
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.
Only use subTest in a loop. This one should probably just be a separate test method.
formatting to changelog Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Daraan <github.blurry@9ox.net>
The current Unpack alias backport had an issue that it did not resolve correctly during substition.
This PR fixes that the following should hold, or rather that the subscription does not raise a
TypeError
.This fixes #474 and was solved by simply adding the Python 3.12+ code to the alias classes.
Sitenote: This is only slightly related to #103, the code sample there also did not work in 3.11 after the backport was used. However, the error is not related and still persists for <=3.10.