News for hackers. Stuff that matters.
Re:Tests aren’t enough: Case study after adding type hints t... by albrewer on Monday October 18, 2021 @06:12PM (#28912478)
I took a stab at it, there's not enough information to figure out anything more specific:

  from typing import Callable, Any

  def compose(start: Callable[[Any], Any], *args: Callable[[Any], Any] -> Callable[[Any], Any]:
    def helper(x: Any) -> Any:
      for func in reversed(args):
        x = func(x)
      return start(x)
    return helper
Re:Tests aren’t enough: Case study after adding type hints t... by slaymaker1907 on Monday October 18, 2021 @06:18PM (#28912534)
Sure, that's probably as close as you can get, but ideally it would be possible to write a type which guarantees the input functions are compatible as well as knowing what the type is of the returned function.