v2.13.0b1
Breaking Changes📦 pydanticView on GitHub →
⚠ 1 breaking✨ 2 features🐛 11 fixes🔧 6 symbols
Summary
This beta release focuses on bug fixes and performance improvements for validation and serialization, notably introducing the `polymorphic_serialization` option and updating the internal `pydantic-core` repository structure.
⚠️ Breaking Changes
- PydanticUserError is now raised as a RuntimeError instead of a TypeError. Code relying on catching TypeError for Pydantic validation errors must be updated to catch RuntimeError or PydanticUserError directly.
Migration Steps
- Update code that catches validation errors to catch `RuntimeError` instead of `TypeError` if it was specifically targeting `PydanticUserError`.
- If using polymorphic serialization, review usage of `serialize_as_any` and consider using the new `polymorphic_serialization` option.
✨ New Features
- Added a new `polymorphic_serialization` option, intended to resolve issues related to `serialize_as_any` from v2.12.
- Support for Root models with `Literal` root types as discriminator field types.
🐛 Bug Fixes
- Fixed `FieldInfo` rebuilding when parameterizing generic models with an `Annotated` type.
- Fixed nested model schema deduplication during JSON schema generation.
- Fixed `InitVar` being ignored when used with the `pydantic.Field()` function.
- Fixed support for enums with `NamedTuple` as values.
- Fixed mock validator/serializer deletion in `rebuild_dataclass()`.
- Fixed serialization warning `MISSING` sentinel being emitted in a nested model.
- Fixed serialization of typed dict unions when `exclude_none` is set.
- Fixed type annotation of `field_definitions` in `create_model()`.
- Fixed incorrect dataclass constructor signature when overriding class `kw_only` with `Field()`.
- Fixed serializing complex numbers with negative zero imaginary part.
- Preserved custom docstrings on stdlib dataclasses in JSON schema.