Skip to content

Commit 9aa7509

Browse files
Make NEVR and NEVRA classes hashable (#416)
Make NEVR and NEVRA classes hashable It turns out __hash__() is not implicitly inherited. Related to packit/packit-service#2497. Reviewed-by: Laura Barcziová
2 parents c2be029 + fae9a9b commit 9aa7509

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

specfile/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ def __init__(
9898
def _key(self) -> tuple:
9999
return self.name, self.epoch, self.version, self.release
100100

101+
def __hash__(self) -> int:
102+
return hash(self._key())
103+
101104
def __lt__(self, other: object) -> bool:
102105
if type(other) is not self.__class__:
103106
return NotImplemented
@@ -172,6 +175,9 @@ def __init__(
172175
def _key(self) -> tuple:
173176
return self.name, self.epoch, self.version, self.release, self.arch
174177

178+
def __hash__(self) -> int:
179+
return hash(self._key())
180+
175181
def __lt__(self, other: object) -> bool:
176182
if type(other) is not self.__class__:
177183
return NotImplemented

0 commit comments

Comments
 (0)