.. _magic-value-comparison:

magic-value-comparison / R2004
==============================

**Message emitted:**

Consider using a named constant or an enum instead of '%s'.

**Description:**

*Using named constants instead of magic values helps improve readability and maintainability of your code, try to avoid them in comparisons.*

**Problematic code:**

.. literalinclude:: /data/messages/m/magic-value-comparison/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/m/magic-value-comparison/good.py
   :language: python




.. note::
  This message is emitted by the optional :ref:`'magic-value'<pylint.extensions.magic_value>`
   checker which requires the ``pylint.extensions.magic_value`` plugin to be loaded.

Created by the `magic-value <https://github.com/PyCQA/pylint/blob/main/pylint/extensions/magic_value.py>`__ checker.