Upgrade to Pydantic 2.12
Recipe ID
org.openrewrite.python.migrate.pydantic.UpgradeToPydantic212Artifactopenrewrite-migrate-pythonMigrate 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.
Composite recipepythonpydanticmigration2.12Proprietary
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.python.migrate.pydantic.UpgradeToPydantic212If the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-pythonDefinition
This recipe runs the following recipes in order.
- Upgrade to Pydantic 2.11
org.openrewrite.python.migrate.pydantic.UpgradeToPydantic211 - Find
serialize_as_anyusage affected by the Pydantic 2.12 unificationorg.openrewrite.python.migrate.pydantic.FindSerializeAsAnyUsage - Find
@model_validator(mode='after')on a classmethodorg.openrewrite.python.migrate.pydantic.FindModelValidatorAfterClassmethod