Change8

v2.13.0b3

📦 pydanticView on GitHub →
3 features🐛 12 fixes🔧 7 symbols

Summary

This beta release introduces new features like `ascii_only` for string constraints and support for `exclude_if` in computed fields, alongside numerous fixes related to unions, JSON schema generation, and model construction.

✨ New Features

  • Added `ascii_only` option to `StringConstraints`.
  • Support for `exclude_if` in computed fields.
  • Constraints are now pushed down in unions involving the `MISSING` sentinel.

🐛 Bug Fixes

  • Fixed tracking of extra fields set after init in `model_fields_set`.
  • Annotations that are not part of named tuple fields are no longer included.
  • The library no longer falls back to trying all union members when the variant selected by the discriminator fails to serialize.
  • Fixed support for discriminator metadata outside the union type alias.
  • Ensured `extras_schema` is respected when only `extra_fields_behavior` is set on the config during JSON Schema generation for typed dictionaries.
  • Ensured `__pydantic_private__` is set in `model_construct()` when using a user-defined `model_post_init()`.
  • Handled all schema generation errors in `InstanceOf`.
  • Allowed dynamic models created with `create_model()` to be used as annotations in the Mypy plugin.
  • Added check for `PlaceholderNode` in the Mypy plugin.
  • Attempt other branches in smart union in case of omit errors.
  • Patched unset attributes with `MISSING` during model serialization when `exclude_unset` is used.
  • Ensured custom `__init__()` is called when using `model_validate_strings()`.

Affected Symbols