Comparison to true should be 'if cond is true:' or 'if cond:' (E712)
When comparing a variable to True
, you should use the form if x is True
or simply if x
. The most common incorrect form is if x == True
.
Anti-pattern
x = True
if x == True:
print('True!')
Best practice
x = True
if x is True:
print('True!')
or simply:
x = True
if x:
print('True!')