Support yaml string tag '!!str'#999
Conversation
fujitatomoya
left a comment
There was a problem hiding this comment.
lgtm with one confirmation for test.
|
@clalancette Could you help to review this PR? |
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
Signed-off-by: Barry Xu <barry.xu@sony.com>
9f0d45a to
6b516f0
Compare
|
Rebase code |
|
@clalancette Thanks for your comments. |
clalancette
left a comment
There was a problem hiding this comment.
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. |
|
created follow-up issue on #1026 |
Address ros2/rclcpp#1983
Support
ros2 run pkg_name exe_name --ros-args -p 'calib:=!!str yes'