Code Monkey home page Code Monkey logo

Comments (12)

crdoconnor avatar crdoconnor commented on May 23, 2024 1

I think we're going around in circles now.

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024

This also happens in maps:

key: key2: value

ruamel.yaml.scanner.ScannerError: mapping values are not allowed here

vs.

key: key2 value

which is a string.

from strictyaml.

crdoconnor avatar crdoconnor commented on May 23, 2024

I'm not exactly sure what it is you are proposing here. Could you clarify?

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024

In the FAQ it says that StrictYAML removes implicit typing, but this is still a thing as shown above.
I've seen YAML files like:

ssh-authorized-keys:
  - sha-rsa AAAB3Nz...
  - sha-rsa AAAB3Nz...

In this case you are kinda lucky because the syntax of the authorized_keys file doesn't contain a colon. Every element in ssh-authorized-keys is a string.
But if it would contain a colon like sha-rsa: AAAB3Nz... those elements will turn into maps but you would assume that the elements are still strings.

from strictyaml.

crdoconnor avatar crdoconnor commented on May 23, 2024

Not if you use validators.

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024
key: key: value
print(load(yaml_string, Map({"key": Str()})).data)
ruamel.yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 9:
    key: key: value
            ^ (line: 1)

from strictyaml.

crdoconnor avatar crdoconnor commented on May 23, 2024

Yes, that isnt valid YAML. If you want to represent that you can do so by escaping though:

key: |
  key: value
key: 'key: value'
>>> print(load(yaml_string, Map({"key": Str()})).data)
{"key": "key: value"}

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024

I know.
Take this for example:

url1: www.google.com
url2: http: //www.google.com

Tell a non-programmer that url2 doesn't work.
It could be even more hidden:
key: superlongrandomstringwhoopsarandomcolonappears: whoops

from strictyaml.

crdoconnor avatar crdoconnor commented on May 23, 2024

So... ?

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024

So now you have:

  • Implicit Typing: key: key: value vs key: key:value
  • Explicit Typing: key: 'key: value' and the pipe syntax + noise
  • Neither non-programmer friendly nor programmer friendly

from strictyaml.

crdoconnor avatar crdoconnor commented on May 23, 2024

Tell a non-programmer that url2 doesn't work.

That's what the error message with line numbers and a code snippet is for - to tell you that the code is invalid.

It could be even more hidden:

key: superlongrandomstringwhoopsarandomcolonappears: whoops

Hidden?

ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 52:
     ... mstringwhoopsarandomcolonappears: whoops
                                         ^ (line: 1)

from strictyaml.

vnc5 avatar vnc5 commented on May 23, 2024

So we have a parser error determined by the content of a value:
key: key: value vs key: key:value
Implicit Typing determined by the content of a value in valid YAML:

array:
  - key: value
  - key:value

which will lead to errors in unvalidated programs.
Validation error determined by the content of a value:

array:
  - key: value

load(yaml_string, Map({"array": Seq(Str())}))

strictyaml.exceptions.YAMLValidationError: when expecting a str
found mapping/sequence
  in "<unicode string>", line 2, column 1:
    - key: value
    ^ (line: 2)

What about the goals stated in the FAQ?

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.