pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

E712: is based on a misreading of PEP8

Open glyph opened this issue 8 years ago • 11 comments

Quoth the specification,

  • Don't compare boolean values to True or False using ==.

    Yes:   if greeting:
    No:    if greeting == True:
    Worse: if greeting is True:
    

pycodestyle considers both the "yes" and the "worse" case equivalently good; if anything, it should complain more about the "Worse" case than the "Yes" one.

It also complains, I believe spuriously, about SQLAlchemy's overridden use of == as described in this Stack Overflow question.

Could this be restricted to just emitting the warning in the literal case of if ... == True:, or is True: which is probably redundant, and leaving more complex expressions alone?

glyph avatar Oct 23 '17 18:10 glyph