Skip to content

E712 Recommendation should be improved #58

@sfariaNG

Description

@sfariaNG

Rule E712 says the best practice is using is when checking a boolean in condition clauses, but according to the document linked in the rule that is not true.

According to https://peps.python.org/pep-0008/#programming-recommendations using is in a conditional is the "worse" solution. The PEP essentially states:

# Correct:
if greeting:

# Wrong:
if greeting == True:

# Worse:
if greeting is True:

This rule should be updated to make the top solution the first recommendation and additional context added for the alternative since they are not semantically the same. In my experience it is a rare case where you need to explicitly check that the type is boolean, but as it stands right now the recommendation can cause subtle bugs in code with inexperienced developers which is the opposite of the purpose of a linter.

Additional discussion in this issue at pycodestyle: PyCQA/pycodestyle#696

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions