Closed Nathanmalnoury closed 2 years ago
Thank you very much! I wasn't aware that sets could be compared.
If I get it right, then a < b
is equivalent to a.issubset(b)
?
And b < a
is equivalent to b.issuperset(a)
?
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 :smiling_face_with_tear:
I guess you meant a > b
in your second example:
a < b
is a.issubset(b) and a != b
a > b
is a.issuperset(b) and a!= b
(Here is the link to python's doc about them: https://docs.python.org/3/library/stdtypes.html#frozenset.issubset)
I think you might have to disable those 4 rules indeed 😬 Sorry about that
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: