← All recipes
Moderne licensed

Reorder comparisons to put literals on the right

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

Swap operands when a constant appears on the left of a comparison, e.g. `42 == count becomes count == 42`, mirroring the relational operator as needed.

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

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

mod config recipes pip install openrewrite-static-analysis