.. _bad-chained-comparison:

bad-chained-comparison / W3601
==============================

**Message emitted:**

``Suspicious %s-part chained comparison using semantically incompatible operators (%s)``

**Description:**

*Used when there is a chained comparison where one expression is part of two comparisons that belong to different semantic groups ("<" does not mean the same thing as "is", chaining them in "0 < x is None" is probably a mistake).*

**Problematic code:**

.. literalinclude:: /data/messages/b/bad-chained-comparison/bad.py
   :language: python

**Correct code:**

.. literalinclude:: /data/messages/b/bad-chained-comparison/good.py
   :language: python



**Related links:**

- `Comparison Chaining <https://docs.python.org/3/reference/expressions.html#comparisons>`_


Created by the `bad-chained-comparison <https://github.com/PyCQA/pylint/blob/main/pylint/checkers/bad_chained_comparison.py>`__ checker.