if-expr-with-false-true
What it does
Section titled “What it does”Reports a conditional expression whose arms are False and True: False if a else True.
Why it matters
Section titled “Why it matters”The expression is not a, written the long way round.
To fix, write not a.
Example
Section titled “Example”...x = not a == b == c...x = False if a else Truex = 1 if a else 1...x = b if a else a...x = not a == b == c...x = False if a else Truex = 1 if a else 1...x = b if a else aConfiguration
Section titled “Configuration”python: lint: rules: if-expr-with-false-true: warn # off (default), warn, errorEnabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line if-expr-with-false-true 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 | SIM211 |
full |