multiple-starts-ends-with
What it does
Section titled “What it does”Reports a.startswith(x) or a.startswith(y) and the same with endswith.
Why it matters
Section titled “Why it matters”startswith and endswith accept a tuple of prefixes or suffixes, so one call with (x, y) says the same without repeating the name.
To fix, write a.startswith((x, y)).
Example
Section titled “Example”...x = list(a)x = a.startswith("a") or a.startswith("b")x = a.endswith("a") or a.endswith(("b", "c")) or cx = a.startswith("a") or b.startswith("b")x = a.startswith("a") and a.startswith("b")x = a.startswith("a") or a.endswith("b")...Configuration
Section titled “Configuration”python: lint: rules: multiple-starts-ends-with: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line multiple-starts-ends-with in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| ruff | PIE810 |
full |