Use generator expression instead of list comprehension in iterable-accepting calls
Recipe ID
org.openrewrite.python.cleanup.ComprehensionToGeneratorArtifactopenrewrite-static-analysisFunctions that consume iterables lazily (e.g. any, sum, sorted) do not need a list comprehension -- a generator expression suffices.
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.ComprehensionToGeneratorIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-static-analysis