-
Notifications
You must be signed in to change notification settings - Fork 30
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
_yaml.pyx deletes comments when dumping using recent versions of ruamel.yaml #1495
Comments
It looks to me that the main reasons we are overriding these deep ruamel codepaths are:
The upstream maintainer has suggested pinning the Unfortunately, I very much doubt that pinning the Some potential ways forward:
|
In addition to this, roundtrip_load is deprecated and will be removed. |
Regarding: "For the same reason, to ensure that ruamel.yaml does not normalize scalar values, like turning the user's intentional True into a true, introducing needless changes in their .bst files" I've always wondered why this is done. It seems like borken behaviour and confuses the boundary between YAML declarative files and Python element implementation. If you want to have True value, then it should be a string. |
"To load all scalar values as strings, this helps our internal codepaths in various places and ensures we never treat things like version numbers as if they were float/double values" this is iffier. In cases whether typing is not possible, user errors are quite probably when strict YAML interpretation is used. That said, again, this is about blurring the fact that the input is YAML. By making it really really be treated as regular YAML there will be less pain if you ever end up having to switch to a different YAML implementation. |
I haven't looked very far into the spec, but as far as I can see, types such as booleans or null values are said to have a canonical form, I'm not sure it says anything about what implementations may or may not accept for these forms (like "True", "trUe", "TRUE" etc, it's unclear whether an implementation should support these or not). That said, I also cannot find any recommendations in the standard regarding round tripping behavior - I don't think anyone expects that a scalar value should be forced into it's canonical form as a result of round tripping, and I rather think the point of round tripping is to preserve the original content unless it was modified. I don't think I agree at this point that |
I don't see alternative forms here https://yaml.org/spec/1.2/#id2803629. I think the things you mentioned should be considered strings |
I also consider it wrong if ruamel.yaml normalizes strings to booleans |
Note if BuildStream converts string "True" to boolean and expects ruamel.yaml not to dump it as true, then the bug is clearly in BuildStream. |
Its not completely clear to me,
BuildStream forces all scalars to be treated as strings (both at load and save time) and this works around normalizations while also ensuring that things like version numbers can be written plainly without quotes or complex YAML syntaxes. To refer back to the upstream wontfix issue, we can clearly see that plain usage of |
I've noticed this with ruamel.yaml too. I suggest sticking to |
Also drop roundtrip_load_data that was unused Fixes apache#1495
Also drop roundtrip_load_data that was unused Fixes apache#1495
Also drop roundtrip_load_data that was unused Fixes apache#1495
Also drop roundtrip_load_data that was unused Fixes apache#1495
Also drop roundtrip_load_data that was unused Fixes apache#1495
Also drop roundtrip_load_data that was unused Fixes apache#1495
With recent versions of
ruamel.yaml
, our test casetests/internals/yaml.py::test_roundtrip_dump
is failing, and deleting comments from the test file.This is filed upstream, but is not reproducible with vanilla ruamel, this only happens with our
_yaml.pyx
customizations.ruamel shallow bisection report
Version 0.17.6
Since this version of
ruamel.yaml
, our loading/dumping routine results in deleting comments from theroundtrip-test.yaml
sample file.The
roundtrip-test.yaml
file is changed in the following way:Version 0.17.5
In this version of
ruamel.yaml
, the test is broken more severely with these versions, instead of losing comments we simply get the following crash (which is an instance ofruamel.yaml
issue 385):Version 0.17.4
This is the last version of
ruamel.yaml
which behaves how we expect it to.The text was updated successfully, but these errors were encountered: