literal-comparison / R0123#

Message emitted:

Comparison to literal

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.

Correct code:

def is_an_orange(fruit):
    return fruit == "orange"

Problematic code:

def is_an_orange(fruit):
    return fruit is "orange" # [literal-comparison]

Related links:

Created by the basic checker.