Fix crash on invalid type variable with ParamSpec#15953
Merged
ilevkivskyi merged 4 commits intopython:masterfrom Aug 25, 2023
Merged
Fix crash on invalid type variable with ParamSpec#15953ilevkivskyi merged 4 commits intopython:masterfrom
ilevkivskyi merged 4 commits intopython:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Member
Author
|
@hauntsaninja |
This comment has been minimized.
This comment has been minimized.
JukkaL
approved these changes
Aug 25, 2023
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
Looks good, I have just one idea.
| return list(an_args) | ||
| if any(isinstance(a, (Parameters, ParamSpecType)) for a in an_args): | ||
| # Nested parameter specifications are not allowed. | ||
| return list(an_args) |
Collaborator
There was a problem hiding this comment.
Another option might be to generate an error and return a list with a single any type.
Member
Author
There was a problem hiding this comment.
Yeah, currently this will say something like "Too many arguments", I will check if we can make error messages better on this.
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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.
Fixes #15948
The fix is straightforward: invalid type variable resulted in applying type arguments packing/simplification when we shouldn't. Making the latter more strict fixes the issue.
cc @A5rocks