if-with-same-arms
What it does
Section titled “What it does”Reports two neighbouring branches of an if/elif chain whose bodies are the same.
Why it matters
Section titled “Why it matters”Two branches that do the same thing are one branch with a condition joined by or. Written twice, a later change is made to one and not the other.
To fix, join the conditions with or.
Example
Section titled “Example”...
... x = 1elif b: x = 1
...Configuration
Section titled “Configuration”python: lint: rules: if-with-same-arms: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line if-with-same-arms 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 | SIM114 |
full |