-
Notifications
You must be signed in to change notification settings - Fork 3
Fix Incorrect EntityList equality evaluation #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #537 +/- ##
==========================================
+ Coverage 88.66% 88.67% +0.01%
==========================================
Files 21 21
Lines 2487 2491 +4
==========================================
+ Hits 2205 2209 +4
Misses 282 282 🚀 New features to boost your workflow:
|
@@ -2139,6 +2139,9 @@ def _entities_same_with_direction(entities_1, entities_2): | |||
else: | |||
return False | |||
|
|||
if len(self) != len(entities_to_compare): | |||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code coverage warning is flagging up that there's a subtle problem here. Because our EntityList inherits from list, which defines an empty __ne__(self, other)
, unless our EntityList re-defines __ne__
, !=
is not the opposite of ==
, and checking ent1 != ent2
if ent1 and ent2 are lists, isn't actually calling our comparison code at all!
To resolve this, I think we just need to add a new method in EntityList that is just
def __ne__(self, other):
"""Compare difference of 2 EntityList objects."""
return not self == other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks! I believe with that, it's now working as it should
EntityList equality evaluation was previously evaluating whether the first list was a subset of the second. The new behaviour is as expected.