← All recipes
Moderne licensed

Remove conditional with identical branches

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

Replace if/elif/else chains where every branch has the same body with just the body, since the condition has no effect on what code executes.

Single recipepythonRSPEC-S3923code-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.AllBranchesIdentical

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

mod config recipes pip install openrewrite-migrate-python