Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions cyclonedx/contrib/bom/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

"""Bom related utilities"""

__all__ = ['BomRefDiscriminator', 'BomDependencyGraphFlatMerger']
__all__ = [
'BomRefDiscriminator',
'BomDependencyGraphFlatMerger',
]

from collections.abc import Iterable
from itertools import chain
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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:
Expand Down
Loading