Skip to content

negate-equal-op

Pythonstylefix: unsafedefault: offpython/ruff

Reports not applied to a comparison with ==, as in not a == b.

!= is the operator for that, and it reads without the reader inverting the comparison.

To fix, write a != b.

Reported
...
pass
x = not a == b
...
x = not a < b
x = not a == b == c
...
After the fix
...
pass
x = a != b
...
x = not a < b
x = not a == b == c
...
python:
lint:
rules:
negate-equal-op: warn # off (default), warn, error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line negate-equal-op in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff SIM201 full