Equality Identity
Sourcery refactoring id: equality-identity
Description:
Simplify equality comparisons that are always True
or False
Before:
if 1 == 1:
always_do_this()
if 1 != 1:
never_do_this()
After:
if True:
always_do_this()
if False:
never_do_this()
Explanation:
When comparing a value to itself, the outcome will always be True
, as long as
the equality operator has not been overridden, and this also holds for the
opposite comparison and False
. It is more readable to use a direct comparison
to the boolean value.