Trailing whitespaces in some generated YAML outputs
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
Hey there,
First issue open here (and first in Sourceforge) so I hope I got everything right.
import ruaml.yaml, sys
ruamel.yaml.YAML().dump([f"{'a' * 77} {'a' * 2}"], sys.stdout)
output
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aa
(note the space at the end of the first line)
expected
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aa
(no trailing whitespace)
I've played with numbers (77 and 2) and it seems that sometimes, there's a space, and sometimes (such as 78 1) there's not.
(I'll do my best to try and remember to come here and see the discussion but I can't promise anything)
Hi, I came to open a ticket for the same thing, glad it has been reported before. I maintain a tool to support developers of Ansible plugins, called
andebox. One of the features the tool provides is reformatting the YAML texts containing documentation, within a Python file, and ruamel.yaml is used for that.The latest updates (from 0.18.12 to 0.18.14) have broken tests that were working before - the word wrapping logic has changed but that's OK, I reckon the new logic made more sense, so I adjusted the expected result of my tests. However, I kept having errors. I just found out the reason why, see the excerpt of my test result (I added
|markers around the lines):Note the first and second lines of the
descriptionelement with the trailing spaces by the end of the content. In this test I configured ruamel.yaml to wrap the YAML content at length 40.So, for now, I am sticking to 0.18.12, but it would be nice to see this fixed.
Thank you very much for your work on ruamel.yaml, it is an awesome library.
Actually, I can confirm that this behaviour was introduced in 0.18.13, so definitely sticking to 0.18.12 for now
Hi there, I can confirm that 0.18.15 is passing the tests (in the andebox project).