Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created December 7, 2025 05:51
Show Gist options
  • Select an option

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

Select an option

Save mypy-play/6cdc00f8b70c450ccdc07213c2275581 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from typing import Callable, overload
@overload
def flow[T](x: T) -> T: ...
@overload
def flow[T, U](x: T, f1: Callable[[T], U]) -> U: ...
@overload
def flow[T, U, V](x: T, f1: Callable[[T], U], f2: Callable[[U], V]) -> V: ...
@overload
def flow[T, U, V, W](x: T, f1: Callable[[T], U], f2: Callable[[U], V], f3: Callable[[V], W]) -> W: ...
def flow(x, *funcs):
for func in funcs:
x = func(x)
return x
def main() -> None:
a: int = flow(1)
b: float = flow(1, float)
c: str = flow(1, float, str)
d: int = flow(1, float, str, len)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment