wemake-python-styleguide
wemake-python-styleguide copied to clipboard
WPS508 and chained comparisons
What's wrong
The following code raises a WPS508 code (Found incorrect not
with compare usage):
if not 1.5 < my_num < 3.75:
...
The alternative would be:
if my_num <= 1.5 or my_num >= 3.75:
...
which is probably harder to understand.
The problem is aggravated for longer chains of comparison, or if my_num
was a function call (because in that case the second way is not even valid, as the function would be called multiple times).
How it should be
I think this error should not be raised for chained comparisons.
Flake8 version and plugins
Irrelevant.
pip information
Irrelevant.
OS information
Irrelevant.
Same here. Left a comment to remind of the issue.