The result of certain comparisons can sometimes be inferred from their context and the results of other comparisons. This can be an indication of faulty logic and may result in dead code or infinite loops if, for example, a loop condition never changes its value.

Inspect the code to check whether the logic is correct, and consider simplifying the logical expression.

In the following (real world) example the test obj1 < obj2 is repeated and thus the second test will always be false, and the function _compare will only ever return 0 or -1.

  • Python Language Reference: Comparisons.