-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 crash on invalid type variable with ParamSpec #15953
Conversation
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Jelle Zijlstra <[email protected]>
@hauntsaninja |
This comment has been minimized.
This comment has been minimized.
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.
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) |
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.
Another option might be to generate an error and return a list with a single any type.
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.
Yeah, currently this will say something like "Too many arguments", I will check if we can make error messages better on this.
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
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