Replace Final model fields with a default with ClassVar
Recipe ID
org.openrewrite.python.migrate.pydantic.ReplaceFinalFieldWithClassVarArtifactopenrewrite-migrate-pythonPydantic 2.11 deprecates annotating a model field as Final with a default value (such fields were treated as class variables). Replace Final[X] = default with ClassVar[X] = default, which preserves the existing class-variable behavior and is the replacement Pydantic recommends.
Single recipepythonpydanticmigration2.11Proprietary
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.ReplaceFinalFieldWithClassVarIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-python