Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

(馃悶) TypeGuard passed to a TypeVar becomes Any, not bool #17117

Open
KotlinIsland opened this issue Apr 11, 2024 · 0 comments 路 May be fixed by #17145
Open

(馃悶) TypeGuard passed to a TypeVar becomes Any, not bool #17117

KotlinIsland opened this issue Apr 11, 2024 · 0 comments 路 May be fixed by #17145
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

KotlinIsland commented Apr 11, 2024

topic-typeguard TypeGuard / PEP 647 topic-type-variables

from typing import TypeGuard, TypeVar, Callable

T = TypeVar("T")

def guard(x: object) -> TypeGuard[str]:
    return True

def f(fn: Callable[[object], T]) -> T:
    return fn(1)

reveal_type(f(guard))  # Any

This should be bool, not Any

@KotlinIsland KotlinIsland added the bug mypy got something wrong label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant