From fae9a9b228cb58b2d82462f554bc15511cf5edac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Fri, 27 Sep 2024 17:24:44 +0200 Subject: [PATCH] Make NEVR and NEVRA classes hashable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out `__hash__()` is not implicitly inherited. Signed-off-by: Nikola Forró --- specfile/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/specfile/utils.py b/specfile/utils.py index a628a0f..4ab2368 100644 --- a/specfile/utils.py +++ b/specfile/utils.py @@ -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 @@ -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