>Writing out the types explicitly forces me to think about what will be the actual interface provided by the function, and how can I make it as strict as possible, to make it hard for its callers to use it in a wrong way.
This right here is the super power. Futzing with the types has repeatedly led me to improving an API in one way or another. It is one thing to have a half-formulated idea on, "You pass in a dictionary with these two keys, and just make sure they are there," vs having to explicitly describe the pattern. The code smell becomes unbearable, and I am much more likely to whip up a tidier interface.
>Writing out the types explicitly forces me to think about what will be the actual interface provided by the function, and how can I make it as strict as possible, to make it hard for its callers to use it in a wrong way.
This right here is the super power. Futzing with the types has repeatedly led me to improving an API in one way or another. It is one thing to have a half-formulated idea on, "You pass in a dictionary with these two keys, and just make sure they are there," vs having to explicitly describe the pattern. The code smell becomes unbearable, and I am much more likely to whip up a tidier interface.