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 dump outputs not-to-spec keys #774

Open
zack-littke-smith-ai opened this issue Dec 21, 2023 · 2 comments
Open

yaml dump outputs not-to-spec keys #774

zack-littke-smith-ai opened this issue Dec 21, 2023 · 2 comments

Comments

@zack-littke-smith-ai
Copy link

zack-littke-smith-ai commented Dec 21, 2023

When calling yaml.dump({"y": 1}) I end up with:

y: 1

Which makes sense, until one considers that this key (y) is actually a boolean according to the yaml spec, and is parsed as such by other yaml parsers (for example: https://pkg.go.dev/sigs.k8s.io/yaml) which would read this as:

true: 1

I would instead expect this output from yaml.dump:

"y": 1

I realize that default_style='"' is an option for me, however the written result is extremely verbose / different from a standard yaml file, pretty much defeating the purpose of using yaml in the first place.

Goofy yaml decision aside, I'm quite surprised to find a standard python lib deviating from the spec in this way.

@perlpunk
Copy link
Member

perlpunk commented Dec 21, 2023

There are many issues related to that, see #486 and especially #247
A PR #555 which supports YAML 1.2 is ready, but the decision was made that this should only be available with a new kind of API #700

Then it would be easy to define a "corrected" YAML 1.1 tagset along with the backwards compatible one.

@zack-littke-smith-ai
Copy link
Author

Thanks! I imagine each instance of this sort of issue is quite specific, so did not find those. Feel free to close as dupe, or leave open if you'd prefer to close it alongside the fix.

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

No branches or pull requests

2 participants