question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit Typing in StrictYAML

See original GitHub issue

Consider this YAML:

array:
  - string 1!
  - string: 2?

Which parses into this:

{'array': ['string 1!', {'string': '2?'}]}

The value determines its type. You’ve eliminated this behavior for primitive types:

python: 3.5.3
postgres: 9.3

Both are strings. But there is still implicit typing between string and map.

An array element syntax like:

array:
  -
  key1: value1
  key2: value2
  -
  key1: value1
  key2: value2
  - some: text

would fix this behavior but then it wouldn’t be a subset of YAML anymore 😄

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
crdoconnorcommented, Jul 11, 2017

I think we’re going around in circles now.

0reactions
vnc5commented, Jul 10, 2017

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

why StrictYAML refuses to do implicit typing and so should you
The real fix requires explicitly disregarding the spec - which is why most YAML parsers have it. StrictYAML sidesteps this problem by ignoring...
Read more >
crdoconnor/strictyaml: Type-safe YAML parser and validator.
StrictYAML is a type-safe YAML parser that parses and validates a restricted subset of the YAML specification. Priorities: Beautiful API; Refusing to parse...
Read more >
why StrictYAML refuses to do implicit typing and so should you
The problem is that people try to parse yaml without such schemas, both because that's doable with other languages (eg json) and because...
Read more >
strictyaml 0.1 - PyPI
StrictYAML is a YAML parser that forces you to explicitly type your YAML with a schema before parsing it, eliminating parse surprise bugs...
Read more >
What's Wrong with StrictYAML - Sand Fox
Implicit Typing. x: yes y: null. Example pyyaml/ruamel/poyo: load(yaml) == {"x": True, "y": None}. Example StrictYAML without schema:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found