Migrating to Pydantic v2.12.1
Version v2.12.1 introduces 2 breaking changes. This guide details how to update your code.
Released: 10/13/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
ValidationInfoMultiHostUrlserialize_as_anyRootModelfield_validatormodel_serializerBreaking Changes
●Issue #1
If you were relying on annotations being evaluated during the inspection of validators or serializers, this behavior has been corrected to prevent evaluation.
✓Solution
If your custom validation or serialization logic depended on side effects during annotation evaluation, you may need to move that logic to explicit runtime checks or initialization steps.
●Issue #2
The handling of `None` conversion when targeting Python 3.14 has been adjusted to explicitly convert `None` to `NoneType`.
✓Solution
This is primarily an internal fix for future Python compatibility; users should generally not need to change code unless they were relying on specific pre-3.14 behavior for `None` handling during validation.
Migration Steps
- 1Review your current Pydantic version. This guide applies when migrating from v2.12.0 or earlier to v2.12.1.
- 2Update your Pydantic dependency to version 2.12.1 or later using your package manager (e.g., pip install pydantic>=2.12.1).
- 3If you experienced issues related to validator/serializer inspection or `RootModel` serialization in v2.12.0, test your application thoroughly against v2.12.1.
- 4If you are using Python 3.14, be aware that `None` conversion behavior is now explicitly handled as `NoneType`.
Release Summary
This 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.
Need More Details?
View the full release notes and all changes for Pydantic v2.12.1.
View Full Changelog