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

y|Y|n|N not Recognised as Booleans #247

Open
dennisconrad opened this issue Feb 1, 2019 · 2 comments · May be fixed by #248
Open

y|Y|n|N not Recognised as Booleans #247

dennisconrad opened this issue Feb 1, 2019 · 2 comments · May be fixed by #248
Labels

Comments

@dennisconrad
Copy link

According to https://yaml.org/type/bool.html, y, Y. n, and N are Boolean scalars.

PyYAML, however, does not recognise them as such, and parses them as strings.

Example:

Python 3.6.5 (default, Dec 11 2018, 12:40:45) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.load('yes')
True
>>> yaml.load('y')
'y'
>>> 
@dennisconrad dennisconrad linked a pull request Feb 1, 2019 that will close this issue
@dennisconrad
Copy link
Author

PR: #248

@gar1t
Copy link

gar1t commented Dec 2, 2022

It's really unfortunate that the YAML spec has such an extensive list of values that decode as bool. The single char variants are pretty incredible.

It forces this spelling:

params:
  x: 123
  'y': 456

Without the quotes, the otherwise straight forward spelling of two common parameters has one of those turning up as a boolean.

That's not just idiosyncratic, it's unusable. As a user-facing data-oriented spec I think that's broken.

I was surprised that the PR above had not been merged but after this seeing this problem, I would count PyYAML's treatment of single char spellings of bools as a feature and not a bug. It's unfortunate that the spec goes this far as it presents a nasty trade off between usability and cross system compatibility -- the primary goals of YAML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants