Created
February 16, 2025 19:13
-
-
Save mypy-play/59b8705d6737e1f8f4855d7b2270e7e9 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import TypeVar, Callable | |
| T = TypeVar("T") | |
| def predicate(a: str) -> bool: | |
| return True | |
| def test(f: Callable[[T], bool]) -> tuple[float | T, bool]: | |
| return 1.0, True | |
| a, b = test(predicate) | |
| # ^^^^^^^^^ | |
| # error: Argument 1 to "test" has incompatible type "Callable[[str], bool]"; | |
| # expected "Callable[[float | str], bool]" [arg-type] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment