-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
no error when calling Callable
with ParamSpec
using Concatenate
with not enough args
#14571
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
Comments
I think mypy should indeed emit an error on your code snippet, but not the error you think. Your use of |
@AlexWaygood It is true that the |
Yes, that example illustrates the type-safety issue much more clearly. So that other people do not have to click through to see the snippet, here it is copied out. No mypy errors are emitted, but from typing import Callable, Concatenate, ParamSpec
P = ParamSpec("P")
def decorator(fn: Callable[Concatenate[str, P], None]) -> Callable[P, None]:
def inner(*args: P.args, **kwargs: P.kwargs) -> None:
fn("value")
return inner
@decorator
def foo(s: str, s2: str) -> None:
... |
Seems like this has nothing to do with from typing_extensions import ParamSpec
from typing import Callable
_P = ParamSpec("_P")
def run(predicate: Callable[_P, None], *args: _P.args, **kwargs: _P.kwargs) -> None:
predicate() |
@AlexWaygood Since this is a major problem (not detecting a relatively common problem of forgetting to pass args&kwargs), I'll try to ping someone here once again: are there any blockers that prevent #17323 (green, small, mergeable) from being merged? Is there anyone I can ping to get that patch reviewed? Something wrong there from my side, making the review or the patch implausible/undesired/inefficient/whatever? |
Unfortunately I'm only a triager here so do not have power to merge. I could review, but I also have pretty limited time to work on mypy right now, sadly. I'll post on the mypy maintainer Discord, however |
Thanks sterliakov and DetachHead! |
Uh oh!
There was an error while loading. Please reload this page.
playground
The text was updated successfully, but these errors were encountered: