Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created June 27, 2025 11:27
Show Gist options
  • Save mypy-play/35b7dfd9e1ecb5e1dacfc3545a04e4ec to your computer and use it in GitHub Desktop.
Save mypy-play/35b7dfd9e1ecb5e1dacfc3545a04e4ec to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Callable
class G[T]:
def g[S](self, x: S) -> S | T: ...
def f[T](x: Callable[[G[T]], int]) -> T: ...
def lambda_example[X](x: G[X]) -> X | int:
return x.g(0)
f(lambda_example)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment