Skip to content

Commit

Permalink
fix: __eq__ PublicId, PackageId & Dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrenbelt committed Nov 16, 2022
1 parent 7cd21b5 commit 8e3ce14
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions aea/configurations/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,10 @@ def __repr__(self) -> str:
return f"<{self}>"

def __eq__(self, other: Any) -> bool:
"""Compare with another object."""
return (
isinstance(other, PublicId)
and self.author == other.author
and self.name == other.name
and self.version == other.version
)
"""Check equality."""
if not isinstance(other, self.__class__):
return NotImplemented # Delegate comparison to the other instance's __eq__.
return all(getattr(self, s) == getattr(other, s) for s in self.__slots__)

def __lt__(self, other: Any) -> bool:
"""
Expand Down Expand Up @@ -651,12 +648,10 @@ def __repr__(self) -> str:
return f"PackageId{self.__str__()}"

def __eq__(self, other: Any) -> bool:
"""Compare with another object."""
return (
isinstance(other, PackageId)
and self.package_type == other.package_type
and self.public_id == other.public_id
)
"""Check equality."""
if not isinstance(other, self.__class__):
return NotImplemented # Delegate comparison to the other instance's __eq__.
return all(getattr(self, s) == getattr(other, s) for s in self.__slots__)

def __lt__(self, other: Any) -> bool:
"""Compare two public ids."""
Expand Down Expand Up @@ -878,15 +873,10 @@ def __str__(self) -> str:
return f"{self.__class__.__name__}(name='{self.name}', version='{self.version}', index='{self.index}', git='{self.git}', ref='{self.ref}')"

def __eq__(self, other: Any) -> bool:
"""Compare with another object."""
return (
isinstance(other, Dependency)
and self._name == other._name
and self._version == other._version
and self._index == other._index
and self._git == other._git
and self._ref == other._ref
)
"""Check equality."""
if not isinstance(other, self.__class__):
return NotImplemented # Delegate comparison to the other instance's __eq__.
return all(getattr(self, s) == getattr(other, s) for s in self.__slots__)


Dependencies = Dict[str, Dependency]
Expand Down

0 comments on commit 8e3ce14

Please sign in to comment.