Pydantic
Data & MLData validation using Python type hints
Release History
v2.13.0b23 fixesThis release focuses on bug fixes, including resolving an issue with the backported V1 namespace and improving flexibility in type validation via validate_as().
v2.13.0b1Breaking11 fixes2 featuresThis 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.
v1.10.261 fixThis patch release fixes a syntax error specifically affecting users running Pydantic on Python 3.7.
v1.10.251 featureThis release adds minimal support for Python 3.14 to the Pydantic v1.10 series.
v2.12.51 fixA patch release fixing a pickle error related to the MISSING sentinel in model_construct and providing documentation updates.
v2.12.4Breaking4 fixes2 featuresA patch release fixing regressions in URL building, defaultdict validation, and TypedDict forward references, while improving IP address serialization under serialize_as_any.
v2.12.32 fixes2 featuresThis patch release restores compatibility for 'after' model validator signatures by issuing warnings instead of errors and introduces the FieldInfo.asdict() method.
v2.12.22 fixesThis patch release fixes a corrupted CPython 3.10 wheel for ARM64 and resolves a bug involving recursive generic models with parent classes.
v2.12.1Breaking8 fixesThis patch release addresses several regressions introduced in v2.12.0, specifically focusing on serialization fixes for RootModel and serialize_as_any, as well as Python 3.14 compatibility.
v2.12.0Breaking7 fixes5 featuresPydantic v2.12.0 introduces initial Python 3.14 support, new serialization options like exclude_computed_fields, and various improvements to TypeAdapter and JSON Schema generation.
v2.12.0b1Breaking6 fixes6 featuresPydantic v2.12.0b1 introduces field-level 'exclude_if', the 'ValidateAs' helper, and PEP 728 support, while enforcing stricter pydantic-core version requirements.
v1.10.24Breaking1 fix1 featureThis release introduces a warning for Python 3.14 incompatibility and fixes a plugin issue for mypy v1.18.
v2.11.91 fixPydantic v2.11.9 is a maintenance release that backports changes from version 1.10.23.
v1.10.231 fixThis patch release fixes a compatibility issue with the mypy plugin when using mypy 1.18.
v2.11.81 fixThis patch release addresses a compatibility issue between the Pydantic mypy plugin and mypy version 1.18.
v2.12.0a1Breaking7 fixes5 featuresPydantic v2.12.0a1 introduces initial support for Python 3.14, a new model completion hook, and experimental MISSING sentinels, while refining validator behavior and JSON schema generation.
v2.11.71 fixThis patch release addresses a specific bug in FieldInfo building where instances were not being copied correctly, potentially leading to shared state issues.
v2.11.62 fixesThis patch release addresses internal issues regarding dataclass field rebuilding and ensures original field assignments are correctly preserved on FieldInfo.
v2.11.53 fixesPydantic v2.11.5 is a patch release focusing on fixes for model rebuilding logic and FieldInfo processing.
v2.11.45 fixes1 featureThis release restores the ability to specify configuration and bases simultaneously in create_model() and includes several bug fixes for generics, decimal constraints, and the mypy plugin.
v2.11.31 fixThis patch release fixes an issue where field descriptions were lost during model rebuilding and updates the internal Pydantic V1 copy to version 1.10.21.
v2.11.26 fixesPydantic v2.11.2 is a patch release that includes several bug fixes for private attributes, discriminated unions, and the mypy plugin, alongside a bump to pydantic-core v2.33.1.
v2.11.11 fixPydantic v2.11.1 is a patch release that fixes a specific issue where 'definitions-ref' schemas were being incorrectly overridden when containing serialization metadata.
v2.11.0Breaking7 fixes9 featuresThis release drops support for Python 3.8 and introduces full support for PEP 695 generics and UUID v6-v8. It includes significant performance optimizations for schema building and attribute setting, alongside several URL-related bug fixes.
v2.11.0b21 fix1 featureThis release introduces experimental support for free threading and fixes an issue where the NotRequired qualifier was ignored in stringified annotations.
v2.11.0b1Breaking7 fixes7 featuresPydantic v2.11.0b1 drops Python 3.8 support, introduces full PEP 695 support, and optimizes performance through improved caching and schema building. It also refactors internal schema generation and updates the behavior of Final attributes.
v2.11.0a25 fixes3 featuresPydantic v2.11.0a2 is an alpha release primarily focused on improving build time performance for models and core schema generation, alongside several JSON Schema and serialization bug fixes.
v2.11.0a1Breaking6 fixes5 featuresPydantic v2.11.0a1 is an alpha release focused on improving build-time performance for core schema generation and Pydantic models. It introduces support for PEP 695 syntax and removes support for Python 3.8.
v2.10.62 fixesThis patch release addresses issues with JSON Schema reference collection involving 'examples' keys and fixes Python serialization for URL objects.
v2.10.52 fixesPydantic v2.10.5 is a maintenance release that removes a custom MRO implementation and fixes URL serialization within Union types.
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.
NotImplementedError2 reportsThe "NotImplementedError" in pydantic typically arises when an abstract method or functionality relying on newer Python features (like generics or specific library versions) is not yet fully implemented for the current Python environment. Address this by upgrading pydantic to the latest version, and ensure your Python version meets the minimum requirements for the features being used, potentially updating Python if needed. If the error persists, investigate if the method call is expected to be available or an abstraction that should be implemented by a subclass, and adjust your expectations or provide the specific implementation.
Related 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