← All recipes
Moderne licensed

Simplify temp-variable swap to tuple unpacking

Recipe IDorg.openrewrite.python.cleanup.SwapVariableArtifactopenrewrite-static-analysis

Detect the three-line swap idiom (tmp = x; x = y; y = tmp) and condense it into x, y = y, x using tuple unpacking.

Single recipeProprietary

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.SwapVariable

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

mod config recipes pip install openrewrite-static-analysis