Change8

Migrating to Pydantic v2.11.0

Version v2.11.0 introduces 3 breaking changes. This guide details how to update your code.

Released: 3/27/2025

3
Breaking Changes
5
Migration Steps
12
Affected Symbols

⚠️ Check Your Code

If you use any of these symbols, you need to read this guide:

create_modelFieldInfoBaseModel.model_fieldsBaseModel.model_computed_fieldsAnyUrlTypeAdapterGenerateSchemaModelMetaclassvalidate_callwith_configgenerate_arguments_schemacheck_pydantic_core_version

Breaking Changes

Issue #1

Accessing `model_fields` or `model_computed_fields` directly on an instance of a Pydantic model is deprecated and will raise an error in future versions.

Solution

Access `model_fields` and `model_computed_fields` on the model class instead of the instance. For example, change `instance.model_fields` to `YourModel.model_fields`.

Issue #2

The format for defining fields in `create_model` has been reworked, which might break custom usage of this function.

Solution

Review the usage of `create_model` and update field definitions to match the new expected format, likely involving changes in how default values or FieldInfo objects are passed.

Issue #3

Python 3.8 support has been officially removed.

Solution

Upgrade your environment to use Python 3.9 or newer.

Migration Steps

  1. 1
    Upgrade your Pydantic dependency to the latest version (e.g., v2.11.0 or newer).
  2. 2
    If you are using Python 3.8, you must upgrade your Python environment to 3.9+ as support has been dropped.
  3. 3
    Review any code that accesses `model_fields` or `model_computed_fields` on model instances and update it to access these attributes on the model class instead (e.g., `ModelName.model_fields`).
  4. 4
    If you extensively use `create_model`, check the usage against the updated field definition format described in the underlying PRs (though specific details are not fully provided here, be prepared for potential adjustments).
  5. 5
    If you were relying on specific behavior related to `final` fields with default values, note that a deprecation warning is now raised; consider removing the default value or addressing the warning.

Release Summary

This 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.

Need More Details?

View the full release notes and all changes for Pydantic v2.11.0.

View Full Changelog