-
Notifications
You must be signed in to change notification settings - Fork 664
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
Configure/Customize ruamel.yaml Loading and Dumping #1927
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cognifloyd
force-pushed
the
write-yaml
branch
3 times, most recently
from
February 17, 2022 22:38
1ed8a52
to
853711a
Compare
cognifloyd
commented
Feb 17, 2022
cognifloyd
force-pushed
the
write-yaml
branch
2 times, most recently
from
February 18, 2022 16:00
fa7ae27
to
fc22cc6
Compare
cognifloyd
requested review from
relrod,
ssbarnea and
ganeshrn
and removed request for
a team
February 18, 2022 16:00
cognifloyd
force-pushed
the
write-yaml
branch
6 times, most recently
from
February 21, 2022 22:40
710fa26
to
71ecb16
Compare
The Emitter ensures that root-level sequences (playbooks, task files, etc) are not over-indented without sacrificing indents at other levels. It also changes ruamel.yaml scalar quoting preference from single- to double-quotes.
Make it clear which elements are under test.
It was dedenting a second level sequence when the top-level was a map.
They are very rough (not final)
Sometimes ruamel.yaml splits up the newlines in comments between pre/post comments which makes it a wee bit confusing.
Moes the pre_process_yaml into a method on our YAML subclass. Also handles extra newlines at the end of the YAML file.
cognifloyd
force-pushed
the
write-yaml
branch
from
February 25, 2022 21:15
eadcb6f
to
ef13138
Compare
- move test to test_yaml_utils
cognifloyd
force-pushed
the
write-yaml
branch
from
February 25, 2022 22:11
ef13138
to
01da857
Compare
YAML 1.1 was not important for this test. Just drop it.
cognifloyd
changed the title
Configure ruamel.yaml dumping with custom
Configure/Customize ruamel.yaml Loading and Dumping
Feb 25, 2022
Emitter
OK. I think this is done and ready for review. The changes to the |
ssbarnea
approved these changes
Feb 26, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This configures and improves ruamel.yaml based formatting. One goal is to be compatible with other YAML formatters like prettier. It requires extending several ruamel.yaml components in
ansiblelint.yaml_utils
:ansiblelint.yaml_utils.
ruamel.yaml.
FormattedYAML
YAML
CustomConstructor
constructor.RoundTripConstructor
FormattedEmitter
emitter.Emitter
OctalIntYAML11
scalarint.ScalarInt
Each of these components serves the following purposes:
FormattedYAML
:CustomConstructor
---
) which ruamel.yaml does not preserveFormattedEmitter
---
) and disable explicit end (...
)\n
)CustomConstructor
:OctalIntYAML11
. Without this, ruamel.yaml converted octals to ints in YAML 1.1.OctalIntYAML11
:CustomConstructor
builds this specialint
subclass to preserve its format as an Octal0123
.OctalInt
, but that gets represented as a YAML 1.2 style octal0o123
.FormattedEmitter
:{ key: value }
instead of{key: value}
)This builds on #1926, #1934, and #1936 (and others)
Extracted from #1828.