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 type inference rules #32

Open
rsgalloway opened this issue Dec 17, 2024 · 0 comments
Open

yaml type inference rules #32

rsgalloway opened this issue Dec 17, 2024 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@rsgalloway
Copy link
Owner

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')
@rsgalloway rsgalloway added the bug Something isn't working label Dec 17, 2024
@rsgalloway rsgalloway added this to the Version 1.0.0 milestone Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant