Created
December 7, 2025 05:51
-
-
Save mypy-play/6cdc00f8b70c450ccdc07213c2275581 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 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