Equality Identity
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery refactoring id: equality-identity
Section titled “Sourcery refactoring id: equality-identity”Description:
Section titled “Description:”Simplify equality comparisons that are always True or False
Before:
Section titled “Before:”if 1 == 1: always_do_this()
if 1 != 1: never_do_this()After:
Section titled “After:”if True: always_do_this()
if False: never_do_this()Explanation:
Section titled “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.