Upgrade to Pydantic 2.12

Proprietary

Migrate code affected by changes introduced in Pydantic 2.12 (and 2.10/2.11). Flags serialize_as_any usage affected by the 2.12 unification with the SerializeAsAny annotation, and @model_validator(mode='after') on a classmethod.

org.openrewrite.python.migrate.pydantic.UpgradeToPydantic212
mod run . --recipe=org.openrewrite.python.migrate.pydantic.UpgradeToPydantic212

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Upgrade to Pydantic 2.11
  2. Find serialize_as_any usage affected by the Pydantic 2.12 unification
  3. Find @model_validator(mode='after') on a classmethod