The Python Type Hints That Actually Prevent Bugs
Python’s type hints are optional, which means many codebases have inconsistent coverage - some functions annotated, most not. When coverage is partial, the benefit is also partial. The value of type hints is not documentation. Documentation can be wrong. The value is the ability to run a static type checker (mypy or pyright) and have it find bugs before they reach production. But not all type hints are equally useful. Some annotations describe things that are obvious. Others describe things that are genuinely dangerous - places where a wrong assumption leads to a runtime error. Here are the ones that do the most work. ...