Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created February 16, 2025 19:13
Show Gist options
  • Select an option

  • Save mypy-play/59b8705d6737e1f8f4855d7b2270e7e9 to your computer and use it in GitHub Desktop.

Select an option

Save mypy-play/59b8705d6737e1f8f4855d7b2270e7e9 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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