You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
# 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.
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: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
The text was updated successfully, but these errors were encountered: