true-false-comparison (E712)#
Derived from the pycodestyle linter.
Fix is always available.
What it does#
Checks for equality comparisons to boolean literals.
Why is this bad?#
PEP 8 recommends against using the equality operators ==
and !=
to
compare values to True
or False
.
Instead, use if cond:
or if not cond:
to check for truth values.
If you intend to check if a value is the boolean literal True
or False
,
consider using is
or is not
to check for identity instead.
Example#
Use instead: