← All recipes
Moderne licensed

Remove self-assignments

Recipe IDorg.openrewrite.python.codequality.RemoveSelfAssignmentArtifactopenrewrite-migrate-python

Remove statements inside a function that assign a plain local name to itself (x = x), since they have no effect. Class-body and module-level X = X bind a new name from an enclosing one and are left alone, as are attribute and subscript targets, which run __set__ and __setitem__.

Single recipeRSPEC-S1656pythoncode-qualityProprietary

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.codequality.RemoveSelfAssignment

If the recipe isn’t available locally, install it with:

mod config recipes pip install openrewrite-migrate-python