Skip to content

double-negation (SIM208)

Added in v0.0.213 · Category: complexity · Related issues · View source

Derived from the flake8-simplify linter.

Fix is sometimes available.

What it does

Checks for double negations (i.e., multiple not operators).

Why is this bad?

A double negation is redundant and less readable than omitting the not operators entirely.

Example

not (not a)

Use instead:

a

Fix availability

Outside of a boolean context (such as an if test), the fix wraps the operand in bool(...) unless the operand is already known to be a bool. This rule will emit a diagnostic but not suggest a fix if that wrapper is needed and bool has been shadowed from its builtin binding.

References