← All recipes
Moderne licensed

Merge multiple startswith()/endswith() calls into one

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

When several startswith() or endswith() calls on the same receiver are joined by or, combine them into a single call with a tuple argument. It only fires where the receiver's type resolves to str or bytes, the receiver is a name or attribute, every argument is a string literal of the receiver's kind, and no comment would be lost.

Single recipepythonPIE810cleanupruffProprietary

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

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