mk-fg / pretty-yaml

PyYAML-based module to produce a bit more pretty and readable YAML-serialized data
Do What The F*ck You Want To Public License
135 stars 29 forks source link

Although I'm using string_val_style='plain', a string value is still quoted #39

Closed mnieber closed 3 years ago

mnieber commented 3 years ago
x = {'a':['hello world', 'hi']}
print(pyaml.dump(x, string_val_style='plain'))

outputs

a:
  - 'hello world'
  - hi

whereas I was expecting

a:
  - hello world
  - hi
mk-fg commented 3 years ago

Iirc problem is that style returned by choose_scalar_style is also used in mapping keys, and those don't work with spaces in them, and presumably I didn't find any quick and easy hack to make that method work differently for actual values (without overriding or monkey-patching some large chunks of pyyaml).

Will check it out though, maybe just haven't had time to look into it for more than couple minutes at the time. Thanks for bringing it up.

mk-fg commented 3 years ago

Indeed it wasn't that difficult to detect when such check is made in the context of the mapping key and avoid changing style for all values with spaces that way. Should be fixed in 21.10.1.