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

PyYAML interprets yes, no, on, off as Boolean #613

Closed
sergio-nsk opened this issue Feb 2, 2022 · 1 comment
Closed

PyYAML interprets yes, no, on, off as Boolean #613

sergio-nsk opened this issue Feb 2, 2022 · 1 comment

Comments

@sergio-nsk
Copy link

How to disable this behavior?
10.2.1.2. Boolean

Canonical Form

Either true or false.

What is a reason of such behavior? The valid YAML

bool: [true, false, on, off, yes, no]

is converted to the invalid dictionary

{'bool': [True, False, True, False, True, False]}

but expected to be converted to the dictionary

{'bool': [True, False, 'on', 'off', 'yes', 'no']}

The similar invalid behavior, the YAML

true: 1
false: 0
on: 1
off: 0
yes: 1
no: 0

results in the invalid dictionary

{True: 1, False: 0}

but expected

{True: 1, False: 0, 'on': 1, 'off': 0, 'yes': 1, 'no': 0}
@perlpunk
Copy link
Member

perlpunk commented Feb 2, 2022

That's correct behavior.
pyyaml implements YAML 1.1
You linked to the YAML 1.2 JSON Schema for some reason.
Here's a compact doc of 1.1 and 1.2 schemas:
https://perlpunk.github.io/yaml-test-schema/schemas.html

#486

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