-
-
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
Question: Partial callable signature #6077
Comments
You can do this with callable protocols (https://mypy.readthedocs.io/en/latest/protocols.html#callback-protocols). |
I was not able to make it work with callable protocols either from typing import Any
from typing_extensions import Protocol
class DecoratedF(Protocol):
def __call__(self, a: str, *args: Any) -> None: ...
def g(f: DecoratedF): ...
@g
def f(a: str, b: str) -> None: ... Am I doing smth wrong ? |
This is actually very similar to #5876 (see also a decorator example there). Which is opposite to the idea of callback protocols in some sense. Callback protocols allow to express signatures that are impossible to express using Potentially we can just also allow special meaning for |
We don't want to support a non-standard extension to the callable syntax, so proposed changes should go through the typing issue tracker or typing-sig@. |
Hello,
When using decorators, we often know that the function that will be decorated should take param x and y, but we don't care about the rest of the parameters. Is there currently a way to do this ?
Something like
Callable[[str,...], Any]
would be perfect. It would work forf(x: str)
but also forf(x: str, y: int)
andf(x: str, *args, **kwargs)
The text was updated successfully, but these errors were encountered: