Skip to content

Commit

Permalink
Make NEVR and NEVRA classes hashable
Browse files Browse the repository at this point in the history
It turns out `__hash__()` is not implicitly inherited.

Signed-off-by: Nikola Forró <[email protected]>
  • Loading branch information
nforro committed Sep 27, 2024
1 parent c2be029 commit fae9a9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions specfile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def __init__(
def _key(self) -> tuple:
return self.name, self.epoch, self.version, self.release

def __hash__(self) -> int:
return hash(self._key())

def __lt__(self, other: object) -> bool:
if type(other) is not self.__class__:
return NotImplemented
Expand Down Expand Up @@ -172,6 +175,9 @@ def __init__(
def _key(self) -> tuple:
return self.name, self.epoch, self.version, self.release, self.arch

def __hash__(self) -> int:
return hash(self._key())

def __lt__(self, other: object) -> bool:
if type(other) is not self.__class__:
return NotImplemented
Expand Down

0 comments on commit fae9a9b

Please sign in to comment.