comparison-of-constants / R0133#

Message emitted:

Comparison between constants: '%s %s %s' has a constant value


When two literals are compared with each other the result is a constant. Using the constant directly is both easier to read and more performant. Initializing 'True' and 'False' this way is not required since Python 2.3.

Correct code:

def is_the_answer(meaning_of_life: int) -> bool:
    return meaning_of_life == 42

Problematic code:

def is_the_answer() -> bool:
    return 42 == 42  # [comparison-of-constants]

Created by the basic checker.