Intro to Pydantic, Run-Time Type Checking For Your Dataclasses
summary
Pydantic provides runtime enforcement of Python type annotations with a drop‑in dataclass replacement and a richer BaseModel that adds JSON (serialize/parse_raw), detailed ValidationError.json output, and JSON Schema (Draft 7) export. Example: a waffle-bistro model uses enums plus custom root and field validators to reject invalid topping/style combos and to forbid two creams; validate_arguments decorator (beta) enforces function inputs. Integrations include FastAPI, Quart, Django Ninja, Hypothesis plugin and schemathesis for auto tests.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 2:54Python data classes refresher
- 9:57What is Pydantic
- 11:24Basic runtime type checking
- 14:56JSON serialization support
- 22:26Custom validators
- 28:34Validating function arguments
- 30:42Framework integrations
- 34:13Automatic testing with schemas
- 36:45Building a FastAPI example
- 38:13Advanced Pydantic features
- 40:45Conclusion and Q&A
