Ruff removes the a == 1 condition in the example below when applying the (unsafe) auto-fix.
Consider this source as test.py:
def PLR1714_demo():
a = 1
b = '2'
if a == 1 or b == '2' or b == '3':
pass
Then:
$ ruff --version
ruff 0.4.10
$ ruff check --isolated --select PLR1714 test.py
test.py:4:8: PLR1714 Consider merging multiple comparisons: `b in ('2', '3')`. Use a `set` if the elements are hashable.
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).
$ ruff check --isolated --select PLR1714 --fix --unsafe-fixes test.py
Found 1 error (1 fixed, 0 remaining).
Now the contents of test.py is shown below, where the conditional a == 1 has been removed.
def PLR1714_demo():
a = 1
b = '2'
if b in ('2', '3'):
pass
Ruff removes the
a == 1condition in the example below when applying the (unsafe) auto-fix.Consider this source as test.py:
Then:
Now the contents of test.py is shown below, where the conditional
a == 1has been removed.