85.8 Type Hints as Documentation
Right, let’s talk about type hints. You’ve probably seen them, those little : str and -> int annotations that started popping up in Python 3.5+. Maybe you thought, “Great, now my beautifully dynamic language wants to be Java.” I get it. But hear me out: when used correctly, type hints are the single most effective piece of documentation you can write. They’re executable, they’re right next to your code, and they don’t lie. Unlike that docstring you wrote three years ago and forgot to update, the type hints are part of the function’s signature. They are the contract.