← All recipes
Moderne licensed

Apply De Morgan's law to any(not ...)/all(not ...)

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

When the generator body just negates the loop variable, De Morgan's law lets us eliminate the generator entirely: any(not v for v in seq) becomes not all(seq), and the reverse.

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

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

mod config recipes pip install openrewrite-static-analysis