literal-comparison / R0123ΒΆ
Message emitted:
In '%s', use '%s' when comparing constant literals not '%s' ('%s')
Description:
Used when comparing an object to a literal, which is usually what you do not want to do, since you can compare to a different literal than what was expected altogether.
Problematic code:
def is_an_orange(fruit):
return fruit is "orange" # [literal-comparison]
Correct code:
def is_an_orange(fruit):
return fruit == "orange"
Related links:
Created by the basic checker.