pydantic-v2

Installation
SKILL.md

Pydantic v2

Pydantic v2 (released 2023-06, current stable 2.13 as of 2026-04-19, paired with Python 3.10-3.14 including 3.14 free-threaded builds) is a near-complete rewrite on pydantic-core (Rust). API is similar but not identical to v1 -- several v1 patterns silently break or behave differently. This skill documents the v2 idioms, the v1 migration gotchas, and the FastAPI integration surface.

Notable recent releases:

  • 2.11 (2025): 2x schema build-time improvements, 2-5x memory reduction for nested models, PEP 695/696 generic syntax, experimental free-threaded Python 3.13, validate_by_alias / validate_by_name / serialize_by_alias config (populate_by_name pending v3 deprecation), Path and deque no longer accept constraints (2.11 release).
  • 2.12: Python 3.14 support (PEP 649/749 annotations), experimental MISSING sentinel, exclude_if on fields, ensure_ascii on JSON output, serialize_as_any unified behavior, @model_validator(mode="after") classmethod deprecated -- write as instance method (2.12 release).
  • 2.13 (April 2026): Polymorphic serialization (model_dump(polymorphic_serialization=True)), exclude_if extended to computed fields, ascii_only in StringConstraints, model_fields_set tracks post-instantiation extras (2.13 release).

When to load which section

  • Writing a new model from scratch -> "Core model patterns" + "Validators"
  • Migrating from v1 -> "v1 -> v2 migration checklist"
  • Working with money / decimals -> "Monetary precision (CWE-681 defense)"
  • FastAPI request/response models -> "FastAPI integration"
  • Performance-sensitive hot path -> "Performance notes"
  • Secret handling / redaction -> "Security and secrets"
  • Validation observability or LLM agents -> "PydanticAI and Logfire"
Related skills
Installs
2
GitHub Stars
2
First Seen
Apr 21, 2026