Pydantic
Data & MLData validation using Python type hints
Release History
View all versions →v2.13.54 fixesThis release addresses several bugs related to validator reuse, garbage collection traversal in pydantic-core, and field counting in smart unions.
v2.14.0b1v2.14.0a1Breaking3 fixes2 featuresPydantic v2.14.0a1 drops support for Python 3.9, introduces PyEmscripten platform tag support, and includes several bug fixes and performance improvements, including optimizations in `model_copy()`.
v2.13.41 fixThis release includes packaging updates, bumping the libc version and adapting linker flags on macOS. A bug fix preserves `RootModel` core metadata.
v2.13.31 fixThis release addresses an issue with handling `AttributeError` subclasses when using `from_attributes`.
v2.13.21 fixThis release fixes an issue where ValidationInfo.field_name was missing when using model_validate_json().
v2.13.11 fixThis release fixes an issue where `ValidationInfo.data` was missing when using `model_validate_json()`.
v2.13.02 fixes1 featurePydantic v2.13 introduces support for Python 3.14 and allows default factories of private attributes to accept validated model data. This release also includes several bug fixes and minor changes.
v2.13.0b312 fixes3 featuresThis release introduces new features like `ascii_only` option for `StringConstraints` and support for `exclude_if` in computed fields. It also includes numerous bug fixes and improvements to schema generation and model handling.
v2.13.0b23 fixesThis release includes several bug fixes, including addressing the backported V1 namespace and improving the flexibility of `validate_as()`. It also resolves an issue with walrus operator precedence in `UrlConstraints`.
v2.13.0b1Breaking19 fixes3 featuresThis beta release of Pydantic v2.13 focuses on bug fixes and performance improvements for validation and serialization. It introduces a new `polymorphic_serialization` option and merges the `pydantic-core` repository into the main Pydantic project.
v1.10.261 fixThis release fixes a syntax error that occurred under Python 3.7. The full changelog provides more details on the specific changes.
v1.10.251 featureThis release adds minimal support for Python 3.14. The full changelog provides details on the specific changes made.
v2.12.51 fix1 featureThis patch release fixes a pickle error related to the MISSING sentinel and includes documentation improvements. The upcoming v2.13 release will introduce polymorphic serialization.
v2.12.45 fixes1 featureThis patch release fixes regressions, reverts a change in URL building for AnyUrl and Dsn types, and addresses serialization issues with IP address types.
v2.12.33 fixes2 featuresThis patch release fixes issues with the `FieldInfo` class and reverts a change to model validator signatures, now emitting a deprecation warning instead of an error for inconsistent cases. It also introduces the `FieldInfo.asdict()` method and improves related documentation.
v2.12.22 fixesThis release fixes an issue with a corrupted pydantic-core wheel for CPython 3.10 on manylinux2014_aarch64 and resolves a bug with recursive generic models.
v2.12.18 fixesThis patch release addresses several regressions introduced in the initial v2.12.0 release, including issues with validator inspection, None type conversion, and RootModel serialization.
v2.12.07 fixes5 featuresThis release introduces several new features, including an `extra` parameter for validate functions and options for serialization and URL handling. It also includes various bug fixes and initial support for Python 3.14.
v2.11.10v2.12.0b1Breaking7 fixes6 featuresThis beta release introduces new features like `exclude_if` and `ValidateAs`, enhances temporal type handling, and includes several bug fixes and packaging updates, including a breaking change for incompatible `pydantic-core` versions.
v1.10.24Breaking1 fixAdded a user warning for Python 3.14+ due to Pydantic V1 incompatibility and fixed a mypy plugin issue for mypy v1.18.
v2.11.91 fixThis release backports changes from v1.10.23 to address bug fixes. The full changelog provides details on the specific changes included.
v1.10.231 fixThis release fixes an issue with the mypy plugin, ensuring compatibility with mypy version 1.18.
v2.11.81 fixThis release fixes an issue with the mypy plugin compatibility for mypy version 1.18.
Common Errors
PydanticUserError9 reportsPydanticUserError usually arises from using pydantic features incorrectly, often due to type annotation errors or incompatible usage patterns with new Pydantic versions. Review your model definitions, especially custom validators, RootModel usage, and discriminators defined with Literal, ensuring everything aligns with the expected format as per the Pydantic documentation. Correct type annotations and adapt incompatible code patterns to resolve these user errors.
ValidationError8 reportsValidationError in pydantic usually arises when the input data doesn't conform to the schema defined in your pydantic model, such as incorrect data types or missing required fields. Resolve it by carefully checking the types, formats, and presence of your input data against the model's field definitions, and handle potential type coercion or provide default values where appropriate. Use `try...except ValidationError` blocks to catch and gracefully handle validation issues within your code.
PydanticSerializationError7 reportsPydanticSerializationError often arises when the data type you're trying to serialize isn't directly supported by Pydantic's default serializers or JSON encoding. To fix this, define custom `field_serializer` functions within your Pydantic model's field definitions to handle the specific type needing serialization, converting it into a JSON-serializable format (like a string or number) before the Pydantic `model_dump` call. Ensure your custom serializer is correctly registered and handles the problematic data type as expected during serialization.
PydanticSchemaGenerationError3 reportsPydanticSchemaGenerationError often arises when pydantic encounters unsupported or ambiguous type annotations. To fix it, ensure all type hints are resolvable and supported by pydantic, and enable `arbitrary_types_allowed = True` in your model config if you need to use types that pydantic doesn't natively understand, coupled with a suitable schema generation strategy (`@field_validator` for instance). Consider using `Annotated` to provide extra metadata to guide pydantic in complex cases.
TypeError2 reportsTypeError in Pydantic often arises from incorrect type hints or mismatched argument signatures during model creation or validation, particularly when using newer Pydantic versions with stricter type checking. Carefully review your model definitions, function calls using `_eval_type()`, and custom validators, ensuring that all type hints are accurate and that you are passing arguments with the expected names and types, especially checking for deprecated arguments like `prefer_fwd_module`. Also ensure that you are using a supported Python version, as certain features may be unavailable or produce unexpected errors in specific environments.
SchemaError2 reportsRelated Data & ML Packages
An Open Source Machine Learning Framework for Everyone
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
Tensors and Dynamic neural networks in Python with strong GPU acceleration
scikit-learn: machine learning in Python
Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
Streamlit — A faster way to build and share data apps.
Subscribe to Updates
Get notified when new versions are released