-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
PEP 647 support mishandles higher-order functions #9927
Labels
bug
mypy got something wrong
Comments
Sure! Will do today 👍 |
Yeap, it still fails:
Looking into it. |
Minimal reproduction: from typing import Callable, Iterable, Iterator, List, Optional, TypeVar
T = TypeVar("T")
R = TypeVar("R")
def filter(f: Callable[[T], TypeGuard[R]], it: Iterable[T]) -> Iterator[R]: ...
a: List[Optional[int]]
bb = filter(lambda x: x is not None, a)
reveal_type(bb) # N: Revealed type is "typing.Iterator[Union[builtins.int, None]]"
# error, actually it is now: Revealed type is "typing.Iterator[R`2]" |
hauntsaninja
pushed a commit
that referenced
this issue
Oct 31, 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
See #9865 for the initial PEP 647 support (type guards).
I did not manage to get this to work right for higher-order functions, notably combined with overloads.
There's a test that fails: testTypeGuardOverload in check-typeguard.test. The crux is
The text was updated successfully, but these errors were encountered: