Find @model_validator(mode='after') on a classmethod
Recipe ID
org.openrewrite.python.migrate.pydantic.FindModelValidatorAfterClassmethodArtifactopenrewrite-migrate-pythonPydantic 2.12 deprecated @model_validator with mode='after' on a classmethod; the implicit classmethod conversion for after model validators is removed in V3. Such validators should be instance methods (self, no @classmethod). This recipe flags the decorator for review, since the rewrite is not safe to mechanize. field_validator is unaffected.
Single 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.FindModelValidatorAfterClassmethodIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-python