-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
no error issued when calling a decorated function with the wrong argument type #10704
Comments
This appears to be a deficiency in the class _lru_cache_wrapper(Generic[_T]):
__wrapped__: Callable[..., _T]
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
def cache(__user_function: Callable[..., _T]) -> _lru_cache_wrapper[_T]: ... Now that typeshed stubs are starting to incorporate PEP 612 (ParamSpec) support, it could be updated to the following: _P = ParamSpec("_P")
class _lru_cache_wrapper(Generic[_P, _T]):
__wrapped__: Callable[_P, _T]
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
def cache(__user_function: Callable[_P, _T]) -> _lru_cache_wrapper[_P, _T]: ... Mypy doesn't currently have full support for ParamSpec (see this tracking issue), but once that support is added, this should address the issue you've reported. I confirmed that it works with pyright. |
Closing, since the change to typeshed is being tracked in typeshed (any blocking mypy issues should be tracked in a more specific issue than this one). |
To Reproduce
Run mypy on this code and then run the code
The output of the program is:
so type information is available.
Expected Behavior
The lines
factorial("")
and
identity("")
should be both flagged as wrong because the function is called with an incompatible type
Actual Behavior
An error is issued for
identity("")
but not for
factorial("")
As a side note, mypy issues an error
but this is another issue.
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: