How do I disable "simplify chained comparison" in PyCharm?

65 Views Asked by At

I understand that a statement like

if x > y and y > z:
   pass

can be simplified to

if x > y > z:
   pass

but honestly I prefer to have the first one, don't judge me please. Is there a way to disable this option in PyCharm, or maybe a way to not get that warning anymore?

1

There are 1 best solutions below

1
Brian61354270 On BEST ANSWER

Navigate to Editor > Inspections in settings, and under "Python" uncheck the option "Too complex chained comparisons".

The description for this inspection is as follows.

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