From 50ca94abecc7eff33218a921adcab296e6b6710e Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 11 Jun 2026 14:38:59 +0200 Subject: [PATCH 1/2] refactor: simplify `contrib.bom.utils` Signed-off-by: Jan Kowalleck --- cyclonedx/contrib/bom/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cyclonedx/contrib/bom/utils.py b/cyclonedx/contrib/bom/utils.py index 7e51bf04..dfad54ae 100644 --- a/cyclonedx/contrib/bom/utils.py +++ b/cyclonedx/contrib/bom/utils.py @@ -17,7 +17,10 @@ """Bom related utilities""" -__all__ = ['BomRefDiscriminator', 'BomDependencyGraphFlatMerger'] +__all__ = [ + 'BomRefDiscriminator', + 'BomDependencyGraphFlatMerger', +] from collections.abc import Iterable from itertools import chain @@ -94,9 +97,9 @@ def from_bom(cls, bom: 'Bom', prefix: str = 'BomRef') -> 'BomRefDiscriminator': * :attr:`cyclonedx.model.bom.Bom.vulnerabilities` """ return cls(chain( - map(lambda c: c.bom_ref, bom._get_all_components()), - map(lambda s: s.bom_ref, bom.services), - map(lambda v: v.bom_ref, bom.vulnerabilities) + (c.bom_ref for c in bom._get_all_components()), + (s.bom_ref for s in bom.services), + (v.bom_ref for v in bom.vulnerabilities), ), prefix) @@ -153,7 +156,7 @@ def reset(self) -> None: def _flatten_merge(deps: Iterable[Dependency]) -> Iterable[Dependency]: flat: dict['BomRef', list['BomRef']] = {} todos = list(deps) - seen: set[int] = set() + seen = set() while todos: todo = todos.pop() if (todo_id := id(todo)) in seen: From 31b460cca52d62542343d080fefbfd8e5b056ef5 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Thu, 11 Jun 2026 14:39:45 +0200 Subject: [PATCH 2/2] tidy Signed-off-by: Jan Kowalleck --- cyclonedx/contrib/bom/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cyclonedx/contrib/bom/utils.py b/cyclonedx/contrib/bom/utils.py index dfad54ae..9e6712ab 100644 --- a/cyclonedx/contrib/bom/utils.py +++ b/cyclonedx/contrib/bom/utils.py @@ -97,7 +97,7 @@ def from_bom(cls, bom: 'Bom', prefix: str = 'BomRef') -> 'BomRefDiscriminator': * :attr:`cyclonedx.model.bom.Bom.vulnerabilities` """ return cls(chain( - (c.bom_ref for c in bom._get_all_components()), + (c.bom_ref for c in bom._get_all_components()), (s.bom_ref for s in bom.services), (v.bom_ref for v in bom.vulnerabilities), ), prefix)