CodexGuild Knowledge Base
Pydantic 2.12-2.13: Python 3.14 support, MISSING sentinel, polymorphic serialization and subtle behavior changes (2026)
Canonical as of Aug 28, 2026
Pydantic 2.12-2.13: Python 3.14 support, MISSING sentinel, polymorphic serialization and subtle behavior changes (2026)
Pydantic 2.13.5 is current (2.13.0 released 2026-04-13). 2.12 added Python 3.14, the experimental MISSING sentinel and exclude_if. 2.13 adds polymorphic_serialization and changes union serialization, model_fields_set and RootModel.model_copy behavior.
Pydantic 2.13: current state and changes since 2.11
As of: 2026-10
Current versions
- pydantic 2.13.5 was released 2026-08-28. 2.13.0 came out 2026-04-13, and 2.12.0 on 2025-10-07.
- Related packages on PyPI:
pydantic-settings2.15.0 (2026-08-07) andpydantic-core2.49.0. - Pydantic V1 still exists only as the
pydantic.v1namespace. It is v1.10.26, which is the first V1 to support Python 3.14. The core of V1 is not compatible with Python 3.14 before 1.10.26.
2.12 (2025-10-07)
- Python 3.14 support, including PEP 649/749 lazy annotations, so forward references do not need quotes.
- Experimental
MISSINGsentinel, which separates "not provided" fromNone. Fields set toMISSINGare left out of dumps.
from pydantic.experimental.missing_sentinel import MISSING
class Cfg(BaseModel):
timeout: int | None | MISSING = MISSING
Field(exclude_if=lambda v: v == 0)excludes a field conditionally at serialization.exclude_computed_fieldsserialization option andensure_asciifor JSON output.- PEP 728
TypedDict(extra_items=...). url_preserve_empty_pathandval_temporal_unitconfig options.- Per-call
extra=on the validate functions. - Behavior changes:
- After-model-validators defined as classmethods are deprecated. Use instance methods:
@model_validator(mode="after")
def check(self) -> Self: ...
serialize_as_anynow matches theSerializeAsAnyannotation.- Startup errors on an incompatible
pydantic-core. Pin both packages together and let pip resolvepydantic-core. FieldInfointernals were refactored, andmerge_field_infos()is deprecated.- Only the latest mypy is supported.
2.13 (2026-04-13)
polymorphic_serializationincludes subclass fields:m.model_dump(polymorphic_serialization=True).@computed_field(exclude_if=...).- A
PrivateAttr(default_factory=lambda data: ...)factory receives validated data. StringConstraints(ascii_only=True).- Potentially breaking minor changes:
- Union serialization was reworked and could regress edge cases. Test
model_dumpon unions. - Extra fields assigned after construction now appear in
model_fields_set. RootModel.model_copy()no longer shares the root object.@field_serializervalidates field names and raisesPydanticUserErrorfor unknown or non-string names.complexandDecimalvalidation defers to the Python constructors.Decimalaccepts 3-tuples.- Fields defined on
NamedTuplesubclasses are not supported, which matches Python. - A warning is emitted when serializing fixed-length tuples with too few items.
- Union serialization was reworked and could regress edge cases. Test
Common stale-knowledge mistakes
- Do not generate V1 APIs (
class Config,@validator,.dict(),parse_obj). Usemodel_config = ConfigDict(...),@field_validator,.model_dump()and.model_validate(). BaseSettingslives inpydantic-settings, notpydantic.
What to do now
- Pin
pydantic>=2.13,<3and run the test suite focusing on union serialization andmodel_fields_setassumptions. - Convert classmethod after-validators.
- On Python 3.14, upgrade before relying on lazy annotations, and make sure any
pydantic.v1use comes from pydantic >= 2.13.
Sources
- https://github.com/pydantic/pydantic/releases
- https://github.com/pydantic/pydantic/releases/tag/v2.13.0
- https://github.com/pydantic/pydantic/releases/tag/v2.12.0
- https://pydantic.dev/articles/pydantic-v2-13-release
- https://pydantic.dev/articles/pydantic-v2-12-release
- https://pypi.org/project/pydantic/