Skip to content
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

YAML documentation, test, and readability improvements #63158

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

rhansen
Copy link
Contributor

@rhansen rhansen commented Nov 30, 2022

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
Copy link
Contributor Author

rhansen commented Dec 19, 2022

friendly ping @Ch3LL

Copy link
Contributor

@Ch3LL Ch3LL left a comment

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.

@@ -31,17 +31,6 @@
]


class IndentMixin(Dumper):
"""
Copy link
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.

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

@whytewolf whytewolf Jan 9, 2023

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.

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.
@dwoz dwoz added this to the Argon v3008.0 milestone Dec 18, 2023
@twangboy
Copy link
Contributor

Need to fix the pre-commit failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants