Skip to content

YAML documentation, test, and readability improvements#63158

Open
rhansen wants to merge 14 commits into
saltstack:3007.xfrom
rhansen:yaml-cleanups
Open

YAML documentation, test, and readability improvements#63158
rhansen wants to merge 14 commits into
saltstack:3007.xfrom
rhansen:yaml-cleanups

Conversation

@rhansen

@rhansen rhansen commented Nov 30, 2022

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Updates the YAML idiosyncrasies documentation
  • Converts the YAML tests to pytest
  • Adds an integration test for map iteration order
  • Minor code health cleanups (no behavior or public API changes)

This PR contains just the (hopefully non-controversial) cleanup commits from #62932.

What issues does this PR fix or reference?

#12161 (can be closed even without this PR because the bug no longer exists, although this PR adds a regression test in the form of an integration test)

Also see PR #62932.

Behavior Changes

No changes, just cleanups.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

No

@rhansen rhansen marked this pull request as ready for review December 1, 2022 06:15
@rhansen rhansen requested a review from a team as a code owner December 1, 2022 06:15
@rhansen rhansen requested review from Ch3LL and removed request for a team December 1, 2022 06:15
@rhansen

rhansen commented Dec 19, 2022

Copy link
Copy Markdown
Contributor Author

friendly ping @Ch3LL

@Ch3LL Ch3LL left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions. I'm also going to reach out to someone else as I'm not intimately familiar with this part of the code.

Comment thread salt/utils/yamldumper.py


class IndentMixin(Dumper):
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot remove a class without properly deprecating it.

Comment thread salt/utils/yamldumper.py
Comment thread salt/utils/yamldumper.py
Comment thread salt/utils/yamldumper.py
Comment thread salt/utils/yamldumper.py
#
# TODO: Why does this registration exist? Isn't it better to raise an
# exception for unsupported types?
D.add_representer(None, represent_undefined)

@whytewolf whytewolf Jan 9, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This representer is only meant for the SafeOrderedDumper not the OrderedDumper. because it is meant to be "safe" alternative to blowing up aka throwing an exception. the OrderedDumper SHOULD blowup on unknown types but SafeOrderedDumper should just null gracefully.

twangboy
twangboy previously approved these changes Jan 10, 2023
twangboy
twangboy previously approved these changes Jun 30, 2026
rhansen and others added 14 commits July 1, 2026 16:39
I believe the behavior changed with commit
002aa88 which was first released in
Salt v2018.3.0.
This demonstrates that saltstack#12161
has already been fixed (thanks to Python 3.6 changing `dict` to
iterate in insertion order).
This does not change the behavior, but it does simplify the code.
The same YAML value can be represented in different ways, so tests
that compare a generated YAML string with a manually typed string are
fragile.  Use `salt.utils.yaml` to generate the reference YAML so that
the implementation of the YAML dumper can change without breaking the
tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-discussion The issue or pull request needs more discussion before it can be closed or merged test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants