-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Repeated revalidate() raises Invalid state #183
Comments
It looks like adding default keys scrambles the order of the state of the 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 |
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 But in fact, would be glad to know if a fix is possible or far away in a pipeline of more urgent stuff... |
I've found some weird bug: calling
revalidate()
for the second time raises anInvalid state
exception when optional fields with default values are present in the schema, but not in the YAML document. Here's a snippet to reproduce the problem.The generated output:
It seems that the type of the field does not matter: I've got the same behavior for
Str
andAny
.On the other hand, the exception is not raised when the YAML object is modified, either by removing the optional value or modifying another one i.e. no exception is raised by the following loops
It looks to me that
revalidate()
uses some internal values that are reset whenever the YAML object is modified, but not otherwise.The text was updated successfully, but these errors were encountered: