Replace len() emptiness check with truthiness
Recipe ID
org.openrewrite.python.cleanup.SimplifyLenComparisonArtifactopenrewrite-static-analysisRewrite `len(seq) > 0 / len(seq) != 0 to seq and len(seq) == 0 to not seq`, leveraging Python's built-in truthiness for collections.
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.SimplifyLenComparisonIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-static-analysis