Giter Site home page Giter Site logo

Comments (2)

aschankler avatar aschankler commented on July 28, 2024

It looks like adding default keys scrambles the order of the state of the YAMLChunk object, leading to inconsistency between the ruamel parsing and the strictyaml parsing. This is the same outcome as in #184, where a failed revalidation leads to inconsistency. In the original example:

from strictyaml import load, Map, Int, Optional

doc = "x: 1"
schema = Map({ "x": Int(), Optional("y", default=42): Int() })
yml = load(doc, schema)

yml._chunk.strictparsed()
# ordereddict([(YAML(x), YAML(1)), (YAML(y), YAML(42))])
yml._chunk.contents
# ordereddict([('x', '1')])

yml.revalidate(schema)
yml._chunk.strictparsed()
# ordereddict([(YAML(y), YAML(42)), (YAML(x), YAML(1))])
yml._chunk.contents
# ordereddict([('x', '1')])

The mismatch between these two internal states causes trouble when resolving keys in YAMLChunk.expect_mapping called by Map.validate.

from strictyaml.

callegar avatar callegar commented on July 28, 2024

I am also experiencing the issue.

Guess it can be worked around by non revalidating... but...

Otherwise, I wonder if dealing with optional stuff by using a MapCombined and to then explicitly look for some keys and add them with the default values if missing would cause the same issue.

But in fact, would be glad to know if a fix is possible or far away in a pipeline of more urgent stuff...

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.