ros2 / ros2/launch

EventHandler should normalize entities into iterable type

Open
#829 0 comments 0 reactions 1 assignee View on GitHub

@wjwwood is already working on this.

Since Mar 6, 2025.

Dominant language
Python
Stars
155
Forks
182
Avg merge
2d 14h
Merged PRs (30d)
6

Description

The problem

https://github.com/ros2/launch/blob/552bfacde39ebbea9c899450ffdcdfd188c61acd/launch/launch/event_handler.py#L105-L137

In above code, entities: Optional[SomeEntitiesType] = None, entities is marked as SomeEntitiesType. It is not normalized in the __init__ function. In the describe function below, it is used as an iterable actions.extend(self.entities).

Besides, noting that in ExecuteLocal, entities is set to a single LaunchDescriptionEntity many times:

            EventHandler(
                matcher=lambda event: is_a_subclass(event, SignalProcess),
                entities=OpaqueFunction(function=self.__on_signal_process_event),
            )

Proposed fix

I plan to fix this by always making the __entities member an iterable (if not None):

        if isinstance(entities, LaunchDescriptionEntity):
            self.__entities = (entities,)
        else:
            self.__entities = entities

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.