-
Notifications
You must be signed in to change notification settings - Fork 105
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
fix: Handle multiline strings in yaml serialization. #935
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #935 +/- ##
=======================================
+ Coverage 80.6% 80.7% +0.1%
=======================================
Files 49 50 +1
Lines 3898 3908 +10
Branches 792 793 +1
=======================================
+ Hits 3145 3157 +12
+ Misses 565 564 -1
+ Partials 188 187 -1 ☔ View full report in Codecov by Sentry. |
@DanCardin I think if you run a |
Signed-off-by: DanCardin <ddcardin@gmail.com>
Signed-off-by: DanCardin <ddcardin@gmail.com>
e96bf7e
to
7b29e30
Compare
😱 neat! An even better way of exemplifying the benefit than my test, lol. Added as a 2nd commit, separate from the actual code change. Just to check, are the literal examples that are being rewritten tested somehow to make sure this hasn't secretly broken the output somehow, even if it looks prettier? |
Yea, they're all tested here! It essentially compares the YAML output but without formatting concerns. As long as the content is valid, the tests pass. Note that we also have Argo Workflows running in CI via k3d and we submit a few workflows to it. Those are created via the some
|
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.
All those examples look sooo much better now 🎖️
We can 🚢 once @elliotgunton or @samj1912 approve too. Their stake in the CLI + YAML is larger than mine, so I want to be mindful of their input |
Co-authored-by: Elliot Gunton <egunton@bloomberg.net> Signed-off-by: DanCardin <DanCardin@users.noreply.github.com>
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.
Awesome stuff! 🚀 The dodgy source dumping has been bugging me forever! 😆
Pull Request Checklist
Description of PR
Currently, multiline strings serialize to yaml in a way that is not true to the original content.
For example, copying argo workflows' exit-handler example
excerpt:
currently produces:
whereas this PR produces:
Note that this does not fix yaml/pyyaml#121 (comment). That is, the following example will revert back to original formatting due to the trailing
\n
at the end of the string.I would suggest switching
ruamel.yaml
over pyyaml just generally, which would fix this issue, but that's probably going to be considered a breaking change.In any case is probably more tangential to the root issue above (which affects both libraries in the same way).