← All recipes
Moderne licensed

Prefer set literals in in membership tests

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

When a list or tuple of literals appears on the right side of an in test, convert it to a set literal for constant-time lookup.

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

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

mod config recipes pip install openrewrite-static-analysis