Skip to content

Commit 28b75bd

Browse files
authored
refactor: simplify contrib.bom.utils (#1000)
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent ebb168a commit 28b75bd

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

cyclonedx/contrib/bom/utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
"""Bom related utilities"""
1919

20-
__all__ = ['BomRefDiscriminator', 'BomDependencyGraphFlatMerger']
20+
__all__ = [
21+
'BomRefDiscriminator',
22+
'BomDependencyGraphFlatMerger',
23+
]
2124

2225
from collections.abc import Iterable
2326
from itertools import chain
@@ -94,9 +97,9 @@ def from_bom(cls, bom: 'Bom', prefix: str = 'BomRef') -> 'BomRefDiscriminator':
9497
* :attr:`cyclonedx.model.bom.Bom.vulnerabilities`
9598
"""
9699
return cls(chain(
97-
map(lambda c: c.bom_ref, bom._get_all_components()),
98-
map(lambda s: s.bom_ref, bom.services),
99-
map(lambda v: v.bom_ref, bom.vulnerabilities)
100+
(c.bom_ref for c in bom._get_all_components()),
101+
(s.bom_ref for s in bom.services),
102+
(v.bom_ref for v in bom.vulnerabilities),
100103
), prefix)
101104

102105

@@ -153,7 +156,7 @@ def reset(self) -> None:
153156
def _flatten_merge(deps: Iterable[Dependency]) -> Iterable[Dependency]:
154157
flat: dict['BomRef', list['BomRef']] = {}
155158
todos = list(deps)
156-
seen: set[int] = set()
159+
seen = set()
157160
while todos:
158161
todo = todos.pop()
159162
if (todo_id := id(todo)) in seen:

0 commit comments

Comments
 (0)