-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Turn on ParamSpec semanal by default #10883
Conversation
This PR does not mean mypy supports PEP 612, but it does do enough to unblock python#10862 mypy should now treat Callable[P, T] as Callable[..., T] and the code paths with incomplete support will no longer crash (but will not do what you'd want)
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.
This is an acceptable way to unblock the use of ParamSpec
in typeshed, though we need real support for ParamSpec
.
Can you also add tests that check that Callable[P, X]
is interpreted as Callable[..., X]
, in a few different contexts (such as in a decorator)?
mypy/applytype.py
Outdated
@@ -19,6 +19,8 @@ def get_target_type( | |||
skip_unsatisfied: bool | |||
) -> Optional[Type]: | |||
# TODO(shantanu): fix for ParamSpecDef | |||
if not isinstance(tvar, TypeVarDef): |
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.
Maybe check specifically for ParamSpecDef so we still hit the assertion if we unexpectedly get some other type. (Same applies to the next change.)
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.
I agree with Jelle's suggestion. So make that change if you agree, but otherwise good to go
This PR does not mean mypy supports PEP 612, but along with #10866 does do enough to
unblock #10862
mypy should now treat Callable[P, T] as Callable[..., T] and the
code paths with incomplete support will no longer crash (but will not do
what you'd want)