R1716 chained-comparison

Message

'Simplify chained comparison between the operands'

Description

This message is emitted when pylint encounters boolean operation like”a < b and b < c”, suggesting instead to refactor it to “a < b < c”

Example

In the following example the chained comparison in fn can be contracted like in fn2.

def fn(value):
    if 0 < value and value < 10:
        print("Value is in range 1-9")

def fn2(value):
    if 0 < value < 10:
        print("Value is in range 1-9")
2:7: R1716: Simplify chained comparison between the operands

Running Pylint locally? In your CI?

There is a better way! Run PyCodeQual & get Pylint findings with history, diffs and statistics.

Click here to find out more.