Skip to content

Commit 3271db7

Browse files
committed
refactor: rework hashing of ...tools / ToolsRepository
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent cf0826c commit 3271db7

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

cyclonedx/model/bom.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ def __eq__(self, other: object) -> bool:
295295
def __hash__(self) -> int:
296296
return hash((
297297
tuple(self.authors), self.component, tuple(self.licenses), self.manufacture, tuple(self.properties),
298-
self.supplier, self.timestamp, tuple(self.tools.tools), tuple(self.tools.components),
299-
tuple(self.tools.services), self.manufacturer,
298+
self.supplier, self.timestamp, self.tools, self.manufacturer,
300299
))
301300

302301
def __repr__(self) -> str:

cyclonedx/model/tool.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ def __eq__(self, other: object) -> bool:
260260
and self._components == other._components \
261261
and self._services == other._services
262262

263+
def __hash__(self):
264+
return hash((tuple(self._tools), tuple(self._components), tuple(self._services)))
265+
263266

264267
class ToolsRepositoryHelper(BaseHelper):
265268
"""

cyclonedx/model/vulnerability.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,7 @@ def __hash__(self) -> int:
13321332
return hash((
13331333
self.id, self.source, tuple(self.references), tuple(self.ratings), tuple(self.cwes), self.description,
13341334
self.detail, self.recommendation, self.workaround, tuple(self.advisories), self.created, self.published,
1335-
self.updated, self.credits, tuple(self.tools.tools), tuple(self.tools.components),
1336-
tuple(self.tools.services), self.analysis, tuple(self.affects), tuple(self.properties)
1335+
self.updated, self.credits, self.tools, self.analysis, tuple(self.affects), tuple(self.properties)
13371336
))
13381337

13391338
def __repr__(self) -> str:

0 commit comments

Comments
 (0)