-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support yaml string tag '!!str' #999
Support yaml string tag '!!str' #999
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with one confirmation for test.
@clalancette Could you help to review this PR? |
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
9f0d45a
to
6b516f0
Compare
Rebase code |
@clalancette Thanks for your comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me with green CI.
Do we really need this? Using "yes" or "no" (i.e. between quotes) should be enough. |
The problem is that there is fundamentally no way to fix it. The YAML specification states that if it sees "yes" or "no", it automatically casts the value to a boolean type. Further, the YAML specification specially allows for The YAML specification actually allows for forcing any type, via something like |
That only applies if the value is unquoted. import yaml
yaml.safe_load("{string_val: 'yes', boolean_val: yes}") The regex of the specification also only matches unquoted values, see https://yaml.org/spec/1.2.2/#1022-tag-resolution (10.2.2 doesn't support The library we're using allows you to check if the value is quoted or not: rcl/rcl_yaml_param_parser/src/parse.c Lines 98 to 99 in 6b516f0
We're actually using that for booleans, so I'm not sure if there's something wrong in the logic. |
as mentioned ros2/rclcpp#1983 (comment), this is correct.
direct solution against ros2/rclcpp#1983, it would be easier just to add quote for user? at least that what i would do instead of adding @Barry-Xu-2018 @iuhilnehc-ynos what do you think? |
Yes, it's also fine to have tags. I wasn't sure if the option of quoting the value was mentioned or not. |
Yeah. It is more convenient for users.
'!!str' is defined in YAML specification. So user may use it. If YAML tag isn't supported, we should tell users this limitation and workaround way in the user manual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
created follow-up issue on #1026 |
Address ros2/rclcpp#1983
Support
ros2 run pkg_name exe_name --ros-args -p 'calib:=!!str yes'