EventHandler should normalize entities into iterable type

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

Maintainers usually reply within 1 day

@wjwwood is already working on this.

Since Mar 6, 2025.

Assessment

This issue has not been assessed yet.

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
Dominant language
Python
Stars
156
Forks
200
Avg merge
2d 11h
Merged PRs (30d)
11

Getting set up

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.

More from ros2/launch

All issues in ros2/launch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.