none-comparison
What it does
Section titled “What it does”Reports a comparison of a value to None with == or !=.
Why it matters
Section titled “Why it matters”None is a single object, and is and is not test for it. == calls __eq__ of the other operand, which a class can define to return true for None (NumPy arrays compare element by element and return an array).
To fix, write x is None or x is not None.
Example
Section titled “Example”x = 1x == Nonex != NoneNone == xNone != xx is Nonex == 1Configuration
Section titled “Configuration”python: lint: rules: none-comparison: warn # off, warn (default), errorSuppress one line with sudsy-disable-next-line none-comparison 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 | E711 |
full |