Giter Site home page Giter Site logo

Comments (9)

daheise avatar daheise commented on May 27, 2024 1

I concur with option two. Particular choice of indent is not as important as consistent indent.

from strictyaml.

crdoconnor avatar crdoconnor commented on May 27, 2024

Yes, this is a good idea.

from strictyaml.

crdoconnor avatar crdoconnor commented on May 27, 2024

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:

  1. Hard code a 2 space indent requirement - advantage - simple, straightforward, makes YAML consistent everywhere, disadvantages - maybe good reason to have other indent?

  2. 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.

  3. Make indent a parameter in load and raise exception if it is violated.

  4. Something else

@guyskk @daheise @Carpetsmoker : comments?

from strictyaml.

guyskk avatar guyskk commented on May 27, 2024

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.

arp242 avatar arp242 commented on May 27, 2024

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.

crdoconnor avatar crdoconnor commented on May 27, 2024

Option two it is. Will implement this today. Thanks guys.

from strictyaml.

arp242 avatar arp242 commented on May 27, 2024

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.

crdoconnor avatar crdoconnor commented on May 27, 2024

Ugh, that's horrible. I didn't even realize that that would parse.

from strictyaml.

crdoconnor avatar crdoconnor commented on May 27, 2024

Oops. This was fixed a on v0.11.0 by the way. I forgot to close here.

from strictyaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.