You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks a lot for this flake8 library, It's been helping us a lot with keeping a nice code quality 1
I think we've spotted a small issue when it comes to replacing not < with >= rules using sets.
Desired change
Rule(s): SIM204, SIM205, SIM206, SIM207
Adjustment:
Using sets, saying not (a < b) is not equivalent to a >= b:
not (a < b): there is no element of a that is in b
a >= b: all elements of b are in a
I am unsure what the adjustment should be, maybe omit these rules when comparing sets ?
Explanation
On sets, (not (a < b)) != (b >= a)
Example
This is an example where the mentioned rule(s) would currently be suboptimal:
a= {4, 5}
b= {1, 2, 3}
# this raises: SIM204 Use 'a >= b' instead of 'not (a < b)'assertnot (a<b) # no elements of a are in b; would pass # when making the suggesting change:asserta>=b# all elements of b are in a -> AssertionError
The text was updated successfully, but these errors were encountered:
Thank you very much! I wasn't aware that sets could be compared.
Understanding the issue
If I get it right, then a < b is equivalent to a.issubset(b)?
And b < a is equivalent to b.issuperset(a)?
Fixing the issue
If that is the case, then those rule suddenly becomes WAY more complicated. The way flake8-simplify works is on the abstract syntax tree. At this level, I don't have any type information. I might need to disable those 4 rules to prevent false-positives 🥲
Hi, thanks a lot for this flake8 library, It's been helping us a lot with keeping a nice code quality 1
I think we've spotted a small issue when it comes to replacing
not <
with>=
rules using sets.Desired change
Using sets, saying
not (a < b)
is not equivalent toa >= b
:not (a < b)
: there is no element of a that is in ba >= b
: all elements of b are in aI am unsure what the adjustment should be, maybe omit these rules when comparing sets ?
Explanation
On sets,
(not (a < b)) != (b >= a)
Example
This is an example where the mentioned rule(s) would currently be suboptimal:
The text was updated successfully, but these errors were encountered: