Skip to content

none-comparison (E711)#

Derived from the pycodestyle linter.

Fix is always available.

What it does#

Checks for comparisons to None 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 != None:
    pass
if None == arg:
    pass

Use instead:

if arg is not None:
    pass