v2.13.0b1Pre-release
v2.13.0b1 2026-02-23
This is the first beta release of the 2.13 version, mainly providing bug fixes and performance improvements for validation and serialization.
Notable changes include:
- Add a new
polymorphic_serializationoption, solving issues withserialize_as_anyintroduced in 2.12. - Latest V1.10.26 release under the
pydantic.v1namespace. This version includes support for Python 3.14. - The
pydantic-corerepository was merged inside the mainpydanticone.
What's Changed
Packaging
- Bump Rust url dependency from 2.5.4 to 2.5.7 in
pydantic-coreby @dependabot[bot] in #12508 - Bump Rust minimum version to 1.88, use edition 2024 by @davidhewitt and @Viicos in #12551 and #12752
- Bump PyO3 to 0.28, jiter to 0.13 by @davidhewitt in #12767
New Features
- Add
polymorphic_serializationoption by @davidhewitt in #12518 - Support Root models with
Literalroot types as discriminator field types by @YassinNouh21 in #12680
Changes
- Migrate
pydantic-coreCI by @Viicos in #12752 - Import
pydantic-coreinto pydantic by @davidhewitt in #12481 - Backport V1 changes up to v1.10.26 by @Viicos in #12663
- Use the
complex()constructor unconditionally when validatingcomplexPython data by @tanmaymunjal in #12498 - Add support for three-tuple input for
Decimalby @tanmaymunjal in #12500 - Align
@field_serializerlogic with@field_validatorby @Viicos in #12577 - Make
PydanticUserErroraRuntimeErrorinstead of aTypeErrorby @poliakovva in #12579 - Remove redundant serialization attempts in nested unions by @davidhewitt in #12604
- Copy
rootvalue when making root model shallow copies by @YassinNouh21 in #12679 - Ensure deterministic JSON schema defaults by sorting sets by @drshvik in #12760
Performance
- Refactor
DecoratorInfos.build()implementation by @Viicos in #12536 - Cache compiled regex in
pydantic-coreby @Viicos in #12549 - Optimize creation of
Literalvalidators by @davidhewitt in #12569 - Optimize implementation of
LookupKeyby @davidhewitt in #12571 - Use python strings for field names by @davidhewitt in #12631
- Optimize datetime formatting code by @davidhewitt in #12626
- Validate JSON model data by iteration by @davidhewitt in #12550
- Optimize annotations evaluation of Pydantic models by @Viicos in #12681
- Optimize
FieldInfo._copy()by @Viicos in #12727
Fixes
- Fix
FieldInforebuilding when parameterizing generic models with anAnnotatedtype by @Viicos in #12463 - Fix nested model schema deduplication in JSON schema generation by @marwan-alloreview in #12494
- Fix
InitVarbeing ignored when using with thepydantic.Field()function by @Viicos in #12495 - Fix support for enums with
NamedTupleas values by @Viicos in #12506 - Do not delete mock validator/serializer in
rebuild_dataclass()by @Viicos in #12513 - Require test suite to pass with free threading, switch back to global generic types cache by @davidhewitt in #12537
- Refactor
__pydantic_extra__annotation handling by @Viicos in #12563 - Do not add claim of UUID "safety" provision by @davidhewitt in #12567
- Use Python hash to perform lookup in tagged union serializer by @davidhewitt in #12594
- Do not emit serialization warning
MISSINGsentinel is present in a nested model by @Viicos in #12635 - Do not eagerly evaluate annotations in signature logic by @Viicos in #12660
- Fix serialization of typed dict unions when
exclude_noneis set by @davidhewitt in #12677 - Do not reuse prebuilt serializers/validators on rebuilds by @lmmx in #12689
- Fix type annotation of
field_definitionsincreate_model()by @lehmann-hqs in #12734 - Fix incorrect dataclass constructor signature when overriding class
kw_onlywithField()by @jfadia in #12741 - Use
typing.Unionwhen replacing types under Python 3.14 by @Viicos in #12733 - Improve ImportString error when internal imports fail by @tsembp in #12740
- Fix serializing complex numbers with negative zero imaginary part by @lhnwrk in #12770
- Preserve custom docstrings on stdlib dataclasses in JSON schema by @nightcityblade in #12815
New Contributors
- @marwan-alloreview made their first contribution in #12494
- @tanmaymunjal made their first contribution in #12498
- @poliakovva made their first contribution in #12579
- @lehmann-hqs made their first contribution in #12734
- @jfadia made their first contribution in #12741
- @tsembp made their first contribution in #12740
- @drshvik made their first contribution in #12760
- @lhnwrk made their first contribution in #12770
- @nightcityblade made their first contribution in #12815