Replace string slicing with removeprefix/removesuffix
Recipe ID
org.openrewrite.python.cleanup.UseStringRemoveAffixArtifactopenrewrite-static-analysisReplace if text.startswith(s): text = text[N:] with text = text.removeprefix(s) and the equivalent endswith pattern with removesuffix (Python 3.9+).
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.UseStringRemoveAffixIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-static-analysis