Skip to content
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions colcon_core/package_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def get_recursive_dependencies(
:raises AssertionError: if a package lists itself as a dependency
"""
if not isinstance(recursive_categories, Mapping):
recursive_categories = defaultdict(lambda: recursive_categories)
non_map_categories = recursive_categories
recursive_categories = defaultdict(lambda: non_map_categories)
Comment on lines +118 to +119
Copy link
Member

Choose a reason for hiding this comment

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

Reading up on lambda captures, you might be able to do this (pardon the line length):

Suggested change
non_map_categories = recursive_categories
recursive_categories = defaultdict(lambda: non_map_categories)
recursive_categories = defaultdict(lambda recursive_categories=recursive_categories: recursive_categories)

but it's not really better than the current solution.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, kind of a horse a piece. It's a tricky behavior - I wish the syntax was cleaner.

# the following variable only exists for faster access within the loop
descriptors_by_name = defaultdict(set)
for d in descriptors:
Expand All @@ -138,7 +139,7 @@ def get_recursive_dependencies(
continue
categories = set()
for category in dep.metadata['categories']:
cats = recursive_categories.get(category)
cats = recursive_categories[category]
if cats is None:
categories = None
break
Expand Down
Loading