I used to think Python type hints were just noise. After refactoring a large script with mypy, I changed my mind.
The turning point
A runtime bug caused by passing a string where an int was expected burned half a day. With type hints and mypy --strict, it would have been caught in seconds.
What I do now
- Type hint every public function
- Run
mypyin CI next to tests - Use
dataclassesandTypedDictfor structured data
It’s not perfect, but it’s way better than guesswork.