PY3.R0133

Comparison of Constants

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.

Noncompliant Code:

Copy
def is_the_answer() -> bool:
    return 42 == 42

Compliant Code:

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

The content on this page is adapted from the Pylint User Guide, Copyright ©2003-2022, Logilab, PyCQA and contributors. All rights reserved. https://pylint.pycqa.org/en/latest/index.html#, and is used under the Python Software Foundation License Version 2. Examples, recipes, and other code in the Pylint documentation are additionally licensed under the Zero Clause BSD License.