Pydantic Cheatsheet 17 — pydantic.dataclasses
Cheatsheet: pydantic.dataclass vs BaseModel, attrs comparison, stdlib dataclass conversion.
Cheatsheet: pydantic.dataclass vs BaseModel, attrs comparison, stdlib dataclass conversion.
Cheatsheet: branded ID types, Decimal for money, phone validation, EmailStr, AwareDatetime.
Cheatsheet: parametrized tests, ValidationError assertions, factories, round-trip tests.
Cheatsheet: method renames, Config → model_config, validator decorators, codemod (bump-pydantic).
Pydantic v2 in production. Model design, validators, serializers, settings, the strict mode, performance characteristics, FastAPI / SQLAlchemy patterns, and the migrations from v1.
Reliable structured output from LLMs in 2026. Pydantic AI, Instructor, OpenAI’s structured outputs / Anthropic tool calling, retry-on-validation patterns, and the end of homemade JSON parsing.
A complete, opinionated production layout for FastAPI in 2026. Pydantic v2, async SQLAlchemy 2.0, Alembic, dependency injection, structured errors, settings, logging, and the project skeleton that survives the first 50 endpoints.
A practical, hands-on introduction to FastAPI covering type-driven routing, Pydantic validation, async I/O, dependency injection, and a sane project layout.