Comments (9)
I concur with option two. Particular choice of indent is not as important as consistent indent.
from strictyaml.
Yes, this is a good idea.
from strictyaml.
I meant to do something about this but I got hit by a bout of analysis paralysis and never picked it up. I'm not sure which of the following is the best course of action:
-
Hard code a 2 space indent requirement - advantage - simple, straightforward, makes YAML consistent everywhere, disadvantages - maybe good reason to have other indent?
-
Simply hard code a requirement that the indention following the first parsed indent should be consistent with the first parsed indent and throw an exception if it isn't.
-
Make indent a parameter in load and raise exception if it is violated.
-
Something else
@guyskk @daheise @Carpetsmoker : comments?
from strictyaml.
Sadly, I prefer 4 space indent... since python use 4 space indent.
I'm glad to see any standard(like PEP8) says YAML should indent 2(4) spaces(no matter 2 spaces or 4 spaces), and everyone follows the same indent.
I like solution 2: Always follow your heart, be consistent from beginning to end.
from strictyaml.
Two spaces seems to be the de-facto standard, as far as I know. It's also what the YAML spec uses. But perhaps this "de-facto" standard differs per programming environment.
One additional option would be to required two spaces, and parse a Vim/Emacs like comment block (# vim ts=4
and whatever the Emacs syntax is) and use the value from that. This is what e.g. Python does for the file encoding.
That being said, option two ("should be consistent with the first parsed indent") is probably the best.
from strictyaml.
Option two it is. Will implement this today. Thanks guys.
from strictyaml.
One issue is that this is difficult to really do correct btw. For example this:
foo:
- one
- two
- three
is (yaml
module):
{'foo': ['one', 'two - three']}
or (strictyaml
module):
YAML(OrderedDict([('foo', ['one', 'two - three'])]))
There are probably other similar cases.
In other words, you never quite know if the indentation is consistent (this is a problem in general, you can never know what the user intended, but even more so with yaml due to its relaxed parsing).
from strictyaml.
Ugh, that's horrible. I didn't even realize that that would parse.
from strictyaml.
Oops. This was fixed a on v0.11.0 by the way. I forgot to close here.
from strictyaml.
Related Issues (20)
- Problem loading document with a single string
- Repeated revalidate() raises Invalid state HOT 2
- Failed revalidation leads to inconsistant state
- Fasjo HOT 3
- Website fails to acknowledge that the Norway problem was fixed in YAML 1.2 HOT 2
- strictyaml does not act as "a near-drop in replacement for pyyaml" HOT 4
- The type order of optional arguments affects the results HOT 2
- Date vs Datetime HOT 2
- Support python2.7.18 HOT 2
- 1.7.0 is broken (cannot import name 'ruamel' from partially initialized module 'strictyaml') HOT 5
- Map containing only Optionals does not validate an empty dict HOT 1
- as_document and load have dissimilar results for CommaSeparated(Int())
- Doesn't Work At All For Lists / Arrays? HOT 4
- New lines after comment line causes `NotImplementedError`
- Feature request/Question: "Optionalize" maps HOT 1
- Thoughts regarding case-sensitivity of keys HOT 6
- Why not: non-Turing complete configuration languages
- Cannot iterate on emtpy list
- BUG: MapCombined documentation different traceback
- Feature: strictyaml.scalar.Time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strictyaml.