← All recipes
Moderne licensed

Collapse for-yield loop into yield from

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

A for-loop that does nothing but yield the loop variable can be expressed as yield from, which is shorter and delegates directly.

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

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

mod config recipes pip install openrewrite-static-analysis