The Case For
Type hints pay off even solo. Your IDE autocomplete becomes dramatically better, mypy catches real bugs (I found a subtle None-return bug in hour one), and code is self-documenting. The overhead is maybe 10% more characters typed.
I've been adding type hints to a 3k-line personal project. Here's my honest verdict.
Type hints pay off even solo. Your IDE autocomplete becomes dramatically better, mypy catches real bugs (I found a subtle None-return bug in hour one), and code is self-documenting. The overhead is maybe 10% more characters typed.
Pyright (from Microsoft, powers Pylance in VSCode) is faster and has better inference than mypy in my experience. Either works — the important thing is to run one of them in your CI. Type hints with no checker are just documentation.
Add this at the top of every file to enable PEP 563 postponed evaluation of annotations. This lets you use forward references without quotes and makes annotation parsing lazy (faster imports). It will become the default eventually.
TypedDict lets you type dictionaries structurally — great for JSON-heavy code. Protocol enables structural subtyping (duck typing with type safety) without inheritance. Together they cover the two main patterns where people give up on type hints in Python.