Change8

v2.12.3

📦 pydanticView on GitHub →
2 features🐛 2 fixes1 deprecations🔧 5 symbols

Summary

This patch release restores compatibility for 'after' model validator signatures by issuing warnings instead of errors and introduces the FieldInfo.asdict() method.

Migration Steps

  1. Upgrade your Pydantic dependency to version 2.12.3 or later.
  2. If you were previously using class methods for model validators decorated with @model_validator(mode='after'), you might now see a warning instead of an error. If you intended to use a class method, ensure your implementation aligns with the expected signature; otherwise, consider using a standard function or instance method.
  3. If you rely on mutating shared `FieldInfo` objects used across multiple `Annotated` definitions, be aware that while mutation support is partially restored, this pattern is explicitly noted as unsupported. Review the documentation example for dynamic models and refactor any code relying on mutable shared `FieldInfo` instances.

✨ New Features

  • Added FieldInfo.asdict() method to the pydantic.fields module.
  • Restored support for mutations on FieldInfo classes when reused as Annotated metadata (though still discouraged).

🐛 Bug Fixes

  • Reverted the strict error enforcement for invalid 'after' model validator signatures to a deprecation warning for consistency.
  • Fixed issues related to the FieldInfo class regarding metadata mutation.

Affected Symbols

⚡ Deprecations

  • Using class methods for 'after' model validators is now deprecated and will emit a warning instead of raising an error.