Closed hjoliver closed 3 years ago
The warning message is incorrect for compound expressions. It can be fixed by enclosing the conditional in parentheses.
This is an example where the mentioned rule(s) would currently be suboptimal wrong:
for x in iterable: if A(x) and B(x): return False return True
Result, with correction:
- SIM111: Use 'return all(not A(x) and B(x) for x in iterable)' + SIM111: Use 'return all(not (A(x) and B(x)) for x in iterable)' ^ ^
or (but you probably don't want to be parsing the expression and doing boolean algebra?):
- SIM111: Use 'return all(not A(x) and B(x) for x in iterable)' + SIM111: Use 'return all(not A(x) or not B(x) for x in iterable)'
Desired change
Explanation
The warning message is incorrect for compound expressions. It can be fixed by enclosing the conditional in parentheses.
Example
This is an example where the mentioned rule(s) would currently be
suboptimalwrong:Result, with correction:
or (but you probably don't want to be parsing the expression and doing boolean algebra?):