Inspectopedia Help

Too complex chained comparisons

Reports chained comparisons that can be simplified.

Example:

def do_comparison(x): xmin = 10 xmax = 100 if x >= xmin and x <= xmax: pass

The IDE offers to simplify if x >= xmin and x <= xmax. When the quick-fix is applied, the code changes to:

def do_comparison(x): xmin = 10 xmax = 100 if xmin <= x <= xmax: pass

Inspection options

Option

Type

Default

Ignore statements with a constant in the middle

Checkbox

false

Inspection Details

Available in:

DataSpell 2023.3, PyCharm 2023.3

Plugin:

Python Community Edition, 233.SNAPSHOT

Last modified: 13 July 2023