python.
A complete site for FastAPI + Pydantic + uv — from setup to production-ready.
Articles
15 postsAsyncio Taskgroup Vs Gather Error Handling
55 minUv Dependency Groups Pep 735 Vs Poetry
56 minPydantic v1 — historical, do NOT copy into v2 verbatim
11 minfastapi-streaming-client-disconnect-cleanup
11 minFastAPI async SQLAlchemy pool_pre_ping pool_recycle production
Tune `AsyncAdaptedQueuePool` with `pool_size=20`, `max_overflow=0`, `pool_pre_ping=True`, `pool_recycle=3600` under sustained FastAPI load — covers the mid-transaction disconnect that pre-ping cannot rescue and when to fall back to `NullPool` on serverless.
11 minFastAPI Lifespan vs Startup/Shutdown: A Migration Guide That Won't Silently Break
Replace deprecated on_startup and on_shutdown handlers with FastAPI's lifespan async context manager. Covers stacking, exception propagation, and the silent-fail trap that catches most migrations.
9 minFastAPI TestClient vs httpx.AsyncClient: When You Actually Need Async Tests
A practical comparison of FastAPI's sync TestClient and httpx.AsyncClient with ASGI transport, including fixture patterns and when each one is the right call.
5 minMocking AsyncAnthropic in pytest: autospec, Response Stubs, and Streaming
Mock the async Anthropic Python SDK in pytest with autospec=True, typed response stubs for messages.create, and async-iterator stubs for streaming completions.
5 minFastAPI Request-ID Middleware: Correlation Across Upstream Services
Build a request-id + structured logging middleware in FastAPI using contextvars, a JSON formatter, and propagation rules that survive async hops and outbound httpx calls.
6 minPydantic Settings v2: Layered Env Config Without the Boilerplate
Build env-driven config in Python with Pydantic Settings v2 — nested models, layered .env overrides, validation, and secret types that survive logs.
6 minFastAPI Background Tasks vs asyncio.create_task vs Redis Queue: When Each Fits
Compare FastAPI BackgroundTasks, asyncio.create_task, and Redis-backed queues like arq. Failure isolation, retry semantics, and the request-timeout boundary that decides which one you reach for.
7 minuv Workspace Setup for a Multi-Package Python Monorepo
A working uv workspace layout for multi-package Python monorepos: root pyproject.toml, member pyproject.toml, local path dependencies, single lockfile strategy, and per-member commands.
6 min