collapsible-if
What it does
Section titled “What it does”Reports an if whose only statement is another if, when neither has an elif or else.
Why it matters
Section titled “Why it matters”The two tests are one condition, if a and b:. The nesting adds an indent level and makes the reader check that nothing else happens between the tests.
To fix, join the tests with and.
Example
Section titled “Example”... pass
if a:... pass
...Configuration
Section titled “Configuration”python: lint: rules: collapsible-if: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line collapsible-if 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 | SIM102 |
full |