← All recipes
Moderne licensed

Remove unnecessary assignment before return

Recipe IDorg.openrewrite.python.cleanup.RemoveUnnecessaryAssignArtifactopenrewrite-migrate-python

Return the value directly where a variable is assigned and then immediately returned. A name that appears anywhere else in the function, a yield value, and a comment before the return are left alone.

Single recipepythoncleanupruffRET504Proprietary

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.cleanup.RemoveUnnecessaryAssign

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

mod config recipes pip install openrewrite-migrate-python
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-python:RELEASE
mod config recipes jar install org.openrewrite:rewrite-python:RELEASE