-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Unclear error message: incompatible type "type[str]"; expected "Callable[[_T], _T]" #17026
Comments
You're attempting to assign a value of type Mypy's error message could arguably be made more clear in this case. For example, here is now pyright reports the error for the same code. |
Sure, and mypy is indeed silenced if you run with
|
|
The issue you're encountering is with the To fix this issue and make it type-check cleanly with mypy, you can explicitly specify the function type for _T = TypeVar("_T") def foo(seq: Sequence[_T]) -> None: By using a lambda function, you're explicitly specifying the type of the function being passed to |
The issue here is that the error message is hard to figure out. We can leave this issue open, but it will be about improving the error message (I'll update the title). |
To Reproduce
Interestingly enough, this error does not fire if you assign to something other than
seq
:mypy 1.9.0 (compiled: yes)
mypy.ini
(and other config files): NonePython 3.12.2
The text was updated successfully, but these errors were encountered: