serhii.net

In the middle of the desert you can say anything you want

27 Sep 2022

Python typing annotating functions and callables

For functions/callables, Callable is not the entire story: you can annotate the arguments and returns values of these callables!

From mypy documentation:

The type of a function that accepts arguments A1, , An and returns Rt is Callable[[A1, ..., An], Rt]."

You can only have positional arguments, and only ones without default values, in callable types

Nel mezzo del deserto posso dire tutto quello che voglio.