Convert and/or ternary trick to conditional expression
Recipe ID
org.openrewrite.python.cleanup.TernaryToIfExpressionArtifactopenrewrite-static-analysisRewrite the legacy cond and val or fallback idiom as val if cond else fallback to avoid silent bugs when val is falsy.
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.TernaryToIfExpressionIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-static-analysis