Type annotations do not reflect that Entity.get_attr()'s data_type parameter can be None
Maintainers usually reply within 1 day
@christophebedard is already working on this.
Since Jun 26, 2025.
Assessment
This issue has not been assessed yet.
Description
Generated by Generative AI
No response
Operating System:
all
ROS version or commit hash:
Rolling
RMW implementation (if applicable):
No response
RMW Configuration (if applicable):
No response
Client library (if applicable):
No response
'ros2 doctor --report' output
No response
Steps to reproduce issue
Run tests downstream of launch with the assumption that data_type can't be None, e.g., https://github.com/ros2/launch/pull/887#issuecomment-2987111760 for #887.
Expected behavior
Tests pass
Actual behavior
Tests fail if we assume that data_type can't be None, see these test failures for #887:
- https://ci.ros2.org/job/ci_linux/24014/testReport/junit/test_launch_ros.test.test_launch_ros.frontend/test_component_container/test_launch_component_container_xml/
- https://ci.ros2.org/job/ci_linux/24014/testReport/junit/test_launch_ros.test.test_launch_ros.frontend/test_node_frontend/test_launch_frontend_xml/
Additional information
See https://github.com/ros2/launch/pull/887#discussion_r2157614696. The type annotation for data_type in launch_xml/launch_yaml's Entity.get_attr() is AllowedTypesType, which does not include None:
launch_xml: https://github.com/ros2/launch/blob/6854fae626f2948139e1734e68d712cc1e0def1b/launch_xml/launch_xml/entity.py#L79launch_yaml: https://github.com/ros2/launch/blob/6854fae626f2948139e1734e68d712cc1e0def1b/launch_yaml/launch_yaml/entity.py#L102
However, the documentation in launch's Entity.get_attr() mentions that data_type can be None, in which case it behaves like str (IIUC), which is the default data_type value: https://github.com/ros2/launch/blob/6854fae626f2948139e1734e68d712cc1e0def1b/launch/launch/frontend/entity.py#L89
Interestingly, launch's Entity.get_attr()'s type annotations are kind of incomplete, especially for data_type. They use TargetType, but that does not specify any type, and, critically, it does not specify None/Optional: https://github.com/ros2/launch/blob/6854fae626f2948139e1734e68d712cc1e0def1b/launch/launch/frontend/entity.py#L46-L76
- Dominant language
- Python
- Stars
- 156
- Forks
- 200
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/launch
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)Possibly taken @Old-Ding claimed this 139 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ros2/launch#978 · 1 reaction ·
Maintainers usually reply within 1 day
-
Add OpaqueFunction to list at docs.ros.orgMay be free again A pull request for this issue was closed without being merged. Openbug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ros2/launch#826 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humblePossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ros2/launch#979 · 6 comments ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
hive size:simple
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
backend enhancement priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
geolens-io/geolens#4161 ·
Maintainers usually reply within 1 day