-
Notifications
You must be signed in to change notification settings - Fork 515
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
Line with extra spaces causes style changes. Bug or Feature? #712
Comments
UPD: removed comment - it turned out to be not yaml bug, but pprint |
This appears to be working as-designed: https://github.com/yaml/pyyaml/blob/6.0.1/lib/yaml/emitter.py#L759-L763 - basically the embedded spaces followed by a break are explicitly disallowed in block scalars by the emitter. It is curious that the parsers preserve it properly in a block scalar though- maybe something that was tightened up in later versions of the spec but the emitter code didn't evolve accordingly? That'd probably be an @ingydotnet question (or someone else more involved in the spec minuatiae). Meantime, I'm going to close the issue for now, since the emitter code does seem to be designed to explicitly prevent this case. |
It's valid YAML. Just that it was decided in PyYAML to disallow this even when literal style is explicitly requested by the user, and there are different opinions on whether it should allow it or not. |
Thanks @perlpunk for the issue necromancy- I've added #121 to the 6.1 planning project. I'm willing to do a little work to try any get this behaving, as well as getting the full YAML test suite integrated (since we're going to want that for a bunch of the other things we're talking about anyway ;) ) |
Versions
Python 3.11.3
PyYAML 6.0
Parameters
Default Style: |
Allow Unicode: True
Input (contains extra spaces on line 3)
Wrong output
Expected output
Code
Solution
Solved it for me by removing extra spaces in the YAML file.
The text was updated successfully, but these errors were encountered: