← All recipes
Moderne licensed

Replace zip(d.keys(), d.values()) with d.items()

Recipe IDorg.openrewrite.python.cleanup.UseItemsForKeyValueIterationArtifactopenrewrite-migrate-python

When both .keys() and .values() are zipped together, replace with .items() which yields key-value pairs directly. Only a zip that a for-loop or comprehension iterates directly is replaced, and only where the receiver is a name or attribute read whose type resolves to dict.

Single recipepythoncleanupruffSIM911Proprietary

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

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

mod config recipes pip install openrewrite-migrate-python
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-python:RELEASE
mod config recipes jar install org.openrewrite:rewrite-python:RELEASE