Skip to content

yaml type inference rules #32

@rsgalloway

Description

@rsgalloway

problem: some unquoted keys (and values) are getting converted on load, e.g. "YES: 1" is converted to "True: 1" automatically. this behavior may be useful on values, but unexpected on keys.

yaml since 1.1 treats certain unquoted strings (like yes, no, on, off, etc.) as booleans. several other potential issues can arise due to YAML’s type inference rules, especially in YAML 1.1, e.g. null, dates and timestamps, boolean-like variants, etc.

potential solutions include quoting problematic keys/values:

  "YES": 1

implementing custom loaders, or disabling the boolean resolver:

yaml.resolver.Resolver.remove_implicit_resolver('tag:yaml.org,2002:bool')

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions