You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 for f(x: str) but also for f(x: str, y: int) and f(x: str, *args, **kwargs)
The text was updated successfully, but these errors were encountered:
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 Callable syntax. However, there is something that can be expressed using Callable that can't be expressed as a signature, for example Callable[..., int] (with literal ...).
Potentially we can just also allow special meaning for *args: Any, **kwds: Anyat the end of a signature to mean "I don't care" instead of "Should allow all possible calls".
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: