Technical
The Python Typing Setup I Use for New Projects
Python without types is fast to start and slow to scale. Every project I start in 2026 begins with a typing setup so I do not add it retroactively. Here is exactly what I configure on day one and why it pays back within a week rather than a year.
The Base Config
rufffor linting (replaces flake8, isort, black in one tool)mypyin strict mode for typespydanticfor runtime data shapespytestwithpytest-mypyfor type testspre-committo enforce all of the above before commits land
The pyproject.toml Block
[tool.ruff]
line-length = 100
select = ["E", "F", "I", "UP"]
[tool.mypy]
strict = true
warn_unused_ignores = true
disallow_any_unimported = trueWhy Strict Mode From Day One
Turning on strict mode later is painful. Starting strict means every new function is properly typed by default. The retrofit cost on a mature project is often more than the original project. I learned this the hard way in 2023 when I tried to strict-type a 40kloc Django codebase and spent three weeks on it.
The Pydantic Layer
Every API boundary uses Pydantic. Not just FastAPI endpoints. Internal function boundaries too, where the shape is complex enough to validate. The runtime checks catch the failures static types cannot. Static types assume the code is correct. Pydantic checks the data at runtime and catches mistakes the types missed.
The Test Discipline
CI runs mypy, ruff, and pytest on every push. No exceptions for quick fixes. The discipline pays itself back the first time a refactor catches a rename that would have shipped in production. One prevented production bug pays for a full year of type maintenance.
The Common Pushback
'Types slow me down on prototypes.' They do, for the first week. Week two onwards, types speed you up because the compiler catches the mistakes you would have made by hand. The crossover is fast enough that I do not bother making exceptions for prototypes anymore.
The Ongoing Cost
Maybe 10 percent more code to write upfront. Maybe 40 percent fewer bugs in production. The math is not close. The mypy documentation has the configuration options in depth if you want to tune beyond the defaults.
RELATED READING
The Consulting Shift I Am Making In Year Two
After a year of writing and building, my consulting practice is changing shape. Shorter engagements. Sharper outcomes.
ReadThe Frontend Shift: Shipping Less JavaScript In Year Two
A year ago I reached for Next.js for everything. This year I often reach for nothing.
ReadThe Serverless Lesson I Would Write On A Sticky Note
After a year of shipping serverless projects, one rule explains most of the wins and all of the losses.
Read