Skip to content

true-false-comparison (E712)#

Derived from the pycodestyle linter.

Fix is always available.

What it does#

Checks for comparisons to booleans which are not using the is operator.

Why is this bad?#

According to PEP 8, "Comparisons to singletons like None should always be done with is or is not, never the equality operators."

Example#

if arg == True:
    pass
if False == arg:
    pass

Use instead:

if arg is True:
    pass
if arg is False:
    pass