Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading