KEMBAR78
Allow plugin signature hooks to return FunctionLike by pranavrajpal · Pull Request #10717 · python/mypy · GitHub
Skip to content

Conversation

pranavrajpal
Copy link
Contributor

This changes the get_method_signature_hook and get_function_signature_hook plugin hooks to let them return any FunctionLike type instead of limiting them to just CallableType.

This allows plugins to return Overloaded for the signature of a function, which is useful if there are multiple possible signatures for a specific function or method call, and the one that gets used is only determined at runtime. This situation came up when working on the singledispatch plugin from #10694.

Change the type of the get_method_signature_hook and
get_function_signature_hook plugin hooks to allow them to return any
FunctionLike type, instead of just CallableType. This allows plugins to
return Overloaded for the type of a function.
@msullivan msullivan merged commit 87a3503 into python:master Jun 26, 2021
pranavrajpal added a commit to pranavrajpal/mypy that referenced this pull request Jun 26, 2021
Change the return type of the plugin hook for determining the signature
of a singledispatch function when it's called to FunctionLike. That
allows us to return Overloaded without needing a 'type: ignore' comment,
which should prevent mypyc from throwing an exception when it sees the
wrong type. This change should be possible now that python#10717 has been
merged.
pranavrajpal added a commit to pranavrajpal/mypy that referenced this pull request Jun 29, 2021
Change the return type of the plugin hook for determining the signature
of a singledispatch function when it's called to FunctionLike. That
allows us to return Overloaded without needing a 'type: ignore' comment,
which should prevent mypyc from throwing an exception when it sees the
wrong type. This change should be possible now that python#10717 has been
merged.
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.

2 participants