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
14 changes: 7 additions & 7 deletions src/buildstream/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
from itertools import chain
import string
from threading import Lock
from typing import cast, TYPE_CHECKING, Dict, Iterator, Iterable, List, Optional, Set, Sequence
from typing import cast, TYPE_CHECKING, Dict, Iterator, Iterable, List, Optional, Set, Sequence, Generator

from pyroaring import BitMap # pylint: disable=no-name-in-module

Expand Down Expand Up @@ -883,8 +883,8 @@ def _dependencies(self, scope: _Scope, *, recurse=True, visited=None):
yield dep
else:

def visit(element, scope, visited):
if scope == _Scope.ALL:
def visit(element: Element, scope: _Scope, visited: tuple[BitMap,BitMap]) -> Generator[Element]:
if scope == _Scope.ALL: # The element, it's runtime and build dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if scope == _Scope.ALL: # The element, it's runtime and build dependencies
if scope == _Scope.ALL: # The element, its runtime and build dependencies

visited[0].add(element._unique_id)
visited[1].add(element._unique_id)

Expand All @@ -893,22 +893,22 @@ def visit(element, scope, visited):
yield from visit(dep, _Scope.ALL, visited)

yield element
elif scope == _Scope.BUILD:
elif scope == _Scope.BUILD: # The element's build dependencies only
visited[0].add(element._unique_id)

for dep in element.__build_dependencies:
if dep._unique_id not in visited[1]:
yield from visit(dep, _Scope.RUN, visited)

elif scope == _Scope.RUN:
# _Scope.BUILD intentionally excludes yielding the element itself.
elif scope == _Scope.RUN: # The element and it's runtime dependencies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
elif scope == _Scope.RUN: # The element and it's runtime dependencies
elif scope == _Scope.RUN: # The element and its runtime dependencies

visited[1].add(element._unique_id)
Comment thread
nathanwilliams-ct marked this conversation as resolved.

for dep in element.__runtime_dependencies:
if dep._unique_id not in visited[1]:
yield from visit(dep, _Scope.RUN, visited)

yield element
else:
else: # _Scope.NONE: Only the element
yield element

if visited is None:
Expand Down
Loading