Skip to content

Commit

Permalink
Make NEVR and NEVRA classes hashable (#416)
Browse files Browse the repository at this point in the history
Make NEVR and NEVRA classes hashable

It turns out __hash__() is not implicitly inherited.
Related to packit/packit-service#2497.

Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored Sep 30, 2024
2 parents c2be029 + fae9a9b commit 9aa7509
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 9aa7509

Please sign in to comment.