Skip to content

Commit

Permalink
fix: PackageVersion.__eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrenbelt committed Nov 16, 2022
1 parent d026c24 commit 7cd21b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion aea/configurations/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class PackageVersion:

_version: PackageVersionLike

__slots__ = ("_version",)

def __init__(self, version_like: PackageVersionLike) -> None:
"""
Initialize a package version.
Expand Down Expand Up @@ -114,7 +116,9 @@ def __str__(self) -> str:

def __eq__(self, other: Any) -> bool:
"""Check equality."""
return isinstance(other, PackageVersion) and self._version == other._version
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 with another object."""
Expand Down

0 comments on commit 7cd21b5

Please sign in to comment.