-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add deflection to custom __lt__
and add functools.total_ordering
#447
Conversation
current remaining failures:
I'm addressing here in this PR:
Addressing in a subsequent PR:
|
self = st.from_type(self_type).example() | ||
copy_self = copy.deepcopy(self) | ||
other = st.from_type(self_type).example() | ||
assert self == copy_self | ||
other = copy.deepcopy(self) | ||
for f in COMPARISON_OPERATORS: | ||
assert isinstance(f(self, other), bool) | ||
assert isinstance(f(other, self), bool) |
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.
we should copy, we don't want to test raising a TypeError
here when certain fields (e.g. author and or name on PublicId
) are not identical. That is done in
open-aea/tests/test_configurations/test_data_types.py
Lines 75 to 98 in 75549e5
@pytest.mark.parametrize("self_type", [PublicId, PackageId, Dependency]) | |
@pytest.mark.parametrize( | |
"other_type", [*NUMERIC_TYPES, *ITERATOR_TYPES, PublicId, PackageId, Dependency] | |
) | |
def test_type_comparison(self_type, other_type): | |
"""Test type comparison""" | |
if self_type is other_type: | |
return | |
funcs = (operator.le, operator.lt, operator.ge, operator.gt) | |
self = st.from_type(self_type).example() | |
other = st.from_type(other_type).example() | |
assert not isinstance(self, other_type) | |
assert not isinstance(other, self_type) | |
assert self.__eq__(self) | |
assert other.__eq__(other) | |
assert self.__ne__(other) | |
assert other.__ne__(self) | |
for f in funcs: | |
with pytest.raises((TypeError, ValueError)): | |
assert f(self, other) |
two remaining failures are newly introduced tests in the base PR:
Delegating comparison to open-aea/aea/helpers/dependency_tree.py Lines 248 to 256 in 45e1c7a
|
Codecov ReportBase: 97.31% // Head: 97.31% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## fix/data_types__eq__ #447 +/- ##
========================================================
- Coverage 97.31% 97.31% -0.01%
========================================================
Files 221 221
Lines 19540 19543 +3
========================================================
+ Hits 19016 19018 +2
- Misses 524 525 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
raise ValueError( | ||
"The public IDs {} and {} cannot be compared. Their author or name attributes are different.".format( | ||
self, other | ||
"""Compare with another object.""" |
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.
The old docstring was nice?
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.
bloat imo
__lt__
and add functools.total_ordering
__lt__
and add functools.total_ordering
bc966d4
to
f269b13
Compare
…nLike Fix/delegate `__lt__` to `PackageVersionLike`
Proposed changes
Adding deflection and
functools.total_ordering
to custom data types with a__lt__
implementation.PackageVersion
,PublicId
andPackageId
.Note that string casting is still using in
__lt__
comparison; in that sense this PR is step 1 out of 2.Fixes
If it fixes a bug or resolves a feature request, be sure to link to that issue.
Types of changes
What types of changes does your code introduce to agents-aea?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply.develop
branch (left side). Also you should start your branch off ourdevelop
.Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...