Python / FastAPI / Pydantic
python.
A complete site for FastAPI + Pydantic + uv — from setup to production-ready.
Articles — Page 2
15 postsPydantic v2 Discriminated Unions: Type-Safe Variants Without the Runtime Tax
How Field(discriminator=...) in Pydantic v2 turns Union parsing from O(n) trial-and-error into O(1) tag dispatch — with Literal tags, mypy support, and real failure modes.
6 minFastAPI Dependency Injection: Designing for Testability
Practical patterns for FastAPI Depends(), sub-dependencies, and dependency_overrides — so your routes stay thin and your pytest fixtures stay sane.
6 minPython Pattern of the Day: Replacing Nested Try/Except with Result Objects
A practical Python pattern for taming nested error handling: model failures as values with a small Result type instead of stacking try/except blocks.
5 min