-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
bool
and TypeGuard
incorrect match in @overload
method
#11307
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
Labels
bug
mypy got something wrong
Comments
Try playing with this line: Line 359 in 1b6f63b
|
Looks like that the problem is more likely here: Lines 475 to 478 in eeafe6b
|
One more weird case: from typing import Callable
from typing_extensions import TypeGuard
def different_typeguard(f: Callable[[object], TypeGuard[str]]): pass
def with_typeguard(o: object) -> TypeGuard[bool]: pass
different_typeguard(with_typeguard) I don't think that this should be allowed. But, right now it is: no errors are shown. |
hauntsaninja
pushed a commit
that referenced
this issue
Oct 30, 2021
tushar-deepsource
pushed a commit
to DeepSourceCorp/mypy
that referenced
this issue
Jan 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While working on python/typeshed#6140 I've noticed that there's a problem with how
TypeGuard
andbool
types match inoverload
method. Here's a simplified example:For some reason
bool
matchesTypeGuard[_T]
and infers_T
to bebool
. I think thatTypeGuard
here is more specific type than justbool
and this match should not happen.The text was updated successfully, but these errors were encountered: