Skip to content

yaml dump outputs not-to-spec keys #774

Open
@zack-littke-smith-ai

Description

@zack-littke-smith-ai

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions