What is the rationale for disabling flow-style arrays?
See original GitHub issueThe docs/why/flow-style-removed.md
outlines the reasonable argument for disabling flow-style mappings:
- The difference between inline mappings and explicit mappings is confusing.
- The curly brackets can denote different things when used as a part of complex toolchain. Notably, Django and Jinja use
{{stuff-like-this}}
for templating; the python itself uses{stuff-like-this}
.
However, I cannot help but notice that all of those arguments are related to flow-style mappings and use only them as examples. Meanwhile, all counterarguments are related to the flow-style arrays, not flow-style mappings.
Is there a reason for disallowing inline arrays? I don’t think anybody uses square brackets for templating, and the both forms of arrays seem natural for me, and easy to understand.
The inspection of code does not show anything problematic: https://github.com/crdoconnor/strictyaml/blob/3b535705d283bcac667e3bdc59be052d9325b13c/strictyaml/parser.py#L210
It seems easy enough to disallow FlowMappingStartToken while tolerating FlowSequenceStartToken.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
I came across the same problem as @honzajavorek : there seems to be no good way of representing an empty array using StrictYAML.
Admittedly, I haven’t thought much about this… but my favorite solution would be to make an exception to the no-flow-style rule for empty arrays (and maybe empty mappings?). Something like this:
Sorry to leave this hanging. I should have responded earlier.
The rationale is pretty much the same as for mapping:
There’s already one, obvious way to represent lists - a dash on each line. I tend to follow the rule of there should be one obvious way of doing things (i.e. the zen of python). This also means that a serializer doesn’t have to “think” or be told about whether to represent a list of things using dash notation or flow style - there is only one way of representing a list.
Related : a goal of StrictYAML was that it should be viewable and editable by non-programmers. I tend to find that non-programmers get confused by this notation (obvious though it is to programmers).
It can be syntactically confusing - especially if you are trying to distinguish strings that have [ and ] vs arrays. I have seen square brackets used for templating as well as several other things that you might want to put in a yaml value.
There are some down sides - notably, that [] is quite a neat way of representing an empty list and for lists that are short it’s nice and compact and readable.