Why this matters
Using == to check for None can fail if an object overrides equality (__eq__). The correct way to check for None is with is, which is more reliable.
is When Comparing with NoneIdentify occurrences where == None or != None is used. Using is None and is not None is more reliable because it checks identity instead of equality, preventing potential issues with overloaded __eq__ methods.
Using == to check for None can fail if an object overrides equality (__eq__). The correct way to check for None is with is, which is more reliable.
Side-by-side examples engineers can pattern-match during review.
if value == None:if value is None:From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.