Improve readability when printing type of classes in error messages#887
Improve readability when printing type of classes in error messages#887ijnek wants to merge 5 commits intoros2:rollingfrom
Conversation
Signed-off-by: ijnek <kenjibrameld@gmail.com>
fujitatomoya
left a comment
There was a problem hiding this comment.
i think this is more user-friendly error message, lgtm with green CI.
|
Pulls: #887 |
Signed-off-by: ijnek <kenjibrameld@gmail.com>
christophebedard
left a comment
There was a problem hiding this comment.
flake8 is complaining about double quotes: https://build.ros2.org/job/Rpr__launch__ubuntu_noble_amd64/284/testReport/junit/launch.test/test_flake8/test_flake8/
./launch/utilities/type_utils.py:317:69: Q000 Double quotes found but single quotes preferred
./launch/utilities/type_utils.py:463:66: Q000 Double quotes found but single quotes preferred
Also, I think ci.ros2.org is broken for unrelated reasons: ros2/ros2#1699
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
Co-authored-by: Christophe Bedard <bedard.christophe@gmail.com> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
|
Pulls: #887 |
christophebedard
left a comment
There was a problem hiding this comment.
Unfortunately, mypy is still complaining 😅
Signed-off-by: ijnek <kenjibrameld@gmail.com>
|
Pulls: #887 |
| attr_error = AttributeError( | ||
| "Attribute '{}' of type '{}' not found in Entity '{}'".format( | ||
| name, data_type, self.type_name | ||
| name, data_type.__name__, self.type_name |
There was a problem hiding this comment.
it's not reflected in the type annotation above, but data_type can be None apparently here and below :/ see the documentation for this method in the base class:
launch/launch/launch/frontend/entity.py
Line 89 in 6854fae
- 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/
I'll open an issue to fix the type annotation.
There was a problem hiding this comment.
I'll open an issue to fix the type annotation.
|
And unfortunately RHEL fails for a different reason here and in some other places where the variable can be a typing class like
I think it's because it's using an older Python version (3.9) in which typing classes like So this would require some workaround for those locations |
|
@ijnek do you mind to take a look ? |
Since the minimum version is 3.9 you can probably replace the |
|
friendly ping @ijnek |
Description
In many places, error messages printed types in a verbose format like '<class 'str'>'. This PR simplifies that by displaying just the type name (e.g. 'str').
For example, given this invalid XML:
The previous error output was:
With this change, it becomes:
Did you use Generative AI?
No