From Pydantic v1 to v2 A Deep Dive Migration for Real Production Systems
summary
Explains a three-repo migration from Pydantic v1 to v2 with concrete steps: Pydantic now splits into pydantic (pure Python) and pydantic_core (Rust), migration options are using bump-pydantic (beta), a phased import alias strategy, or an all‑at‑once disruptive update; run pip show/pip check, upgrade FastAPI first, recreate the venv, and test CI packages together. Highlights breaking changes: Optional[str]=None must be explicit Optional with default, model.dict → model.model_dump, error payloads and locations change, decimals serialize as strings, root_validator → model_validator with mode before/after, and validators become field validators using Annotated.
AI-written summary · about
chapters (10)
- 0:00Pydantic v1 to v2 intro
- 2:13Why v1 needed overhaul
- 4:00Architecture changes in v2
- 6:07Migration strategies
- 8:35Migration checklist
- 11:45Breaking changes in v2
- 15:00Validation errors handling
- 17:30Validator syntax updates
- 19:40CI/CD pipeline tips
- 20:44Q&A
related talks
27mFrom Pydantic V1 to V2
46mHow Pydantic V2 leverages Rust's Superpowers
22mPydantic Power-up: Performance Tips for Lightning-Fast Python Applications
24mJourney to migrate python2 projects to 3
27mHow We Migrated 3.8 Million Lines of Python 2 Without Interrupting Deve...
26mPython 2 is dead! Drag your old code into the modern age
26mIntro to Pydantic, run-time type checking for your dataclasses
42mSo much depends upon... a python app's dependencies
