Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Jul 27, 2021

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)

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)
Copy link
Collaborator

@JukkaL JukkaL left a 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)?

skip_unsatisfied: bool
) -> Optional[Type]:
# TODO(shantanu): fix for ParamSpecDef
if not isinstance(tvar, TypeVarDef):
Copy link
Member

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.)

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Aug 2, 2021

@JukkaL added a test! :-) If you have a minute, could you also take a look at #9951 ? It's been open for several months and simplifies some adjacent code

Copy link
Collaborator

@msullivan msullivan left a 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

@github-actions

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants