Change8

Migrating to Pydantic v2.12.0b1

Version v2.12.0b1 introduces 2 breaking changes. This guide details how to update your code.

Released: 10/2/2025

2
Breaking Changes
4
Migration Steps
7
Affected Symbols

⚠️ Check Your Code

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

pydantic.Fieldpydantic.ValidateAspydantic.main.BaseModel.__getattr__pydantic.dataclasses.dataclasspydantic.networks.AnyUrlpydantic.types.ImportStringpydantic.mypy

Breaking Changes

Issue #1

If an incompatible version of `pydantic-core` is installed, Pydantic will now raise an error instead of potentially failing silently or with cryptic errors.

Solution

Ensure your `pydantic-core` dependency is updated to version v2.40.1 or higher (or compatible with v2.12.0b1) by running `pip install --upgrade pydantic-core` or updating your lock file.

Issue #2

Runtime warnings for experimental features have been removed, meaning code relying on these warnings for behavior changes might need adjustment.

Solution

Review any code that previously relied on runtime warnings for experimental features. If you were using an experimental feature, check the latest documentation for its stable replacement or expected behavior.

Migration Steps

  1. 1
    Update your Pydantic dependency to the latest version (e.g., v2.12.0b1 or later) using your package manager (e.g., `pip install pydantic>=2.12.0b1`).
  2. 2
    Ensure that `pydantic-core` is also updated to a compatible version (v2.40.1 or higher) by running `pip install --upgrade pydantic-core` if you manage dependencies separately.
  3. 3
    If your application previously relied on runtime warnings for experimental features, review the Pydantic documentation for the stable API equivalents.
  4. 4
    If you encounter errors related to validation or assignment on dataclasses, ensure you are using property setters correctly, as behavior has been improved/fixed for `validate_assignment=True`.

Release Summary

Pydantic v2.12.0b1 introduces field-level 'exclude_if', the 'ValidateAs' helper, and PEP 728 support, while enforcing stricter pydantic-core version requirements.

Need More Details?

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

View Full Changelog