Skip to content
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

Be explicit about support for complex YAML keys #252

Open
perrygreenfield opened this issue Jun 19, 2020 · 3 comments
Open

Be explicit about support for complex YAML keys #252

perrygreenfield opened this issue Jun 19, 2020 · 3 comments
Milestone

Comments

@perrygreenfield
Copy link
Contributor

The YAML 1.1 spec permits object keys to themselves be objects or arrays, which isn't well supported by Python (since dicts and lists are not hashable). A more serious issue is that complex keys are not at all covered by JSON Schema, since JSON only supports string keys. Consider declaring in the ASDF Standard that object or array keys are not permitted.

Restricting our tree to a subset of YAML would also offer the benefit of a simplified implementation if we ever decide to write our own fast YAML parser.

One option is to require complex keys be encoded as strings, perhaps with some specification of what is legal. Again, this would requires some thought. We would like to stay away from anything goes for keys.

@embray
Copy link
Contributor

embray commented Jun 23, 2020

Did we ever explicitly say this was supported, or was it just not explicitly unsupported before? I didn't even know (or forgot) that YAML itself supported this.

I have a lot of experience with the guts of PyYAML now and could also probably provide a modified parser that explicitly disallows this.

@jdavies-st
Copy link
Contributor

No, we haven't been explicit, so I think the idea is to be explicit here one way or another. And there's good reason to go for the simple approach that is supported by the existing yaml libraries and jsonschema.

This was initially pointed out in asdf-format/asdf#642 where tuple keys are not supported by any of the python YAML libraries in the way we need.

I think we want to go for simplicity here.

@embray
Copy link
Contributor

embray commented Jun 23, 2020

I think we want to go for simplicity here.

Agreed. I suppose as a middle ground it could still be supported in custom user data, but it definitely shouldn't be allowed by anything which is checked by a schema. And since we want to encourage the use of schemas anyways it seems simplest to just make it an explicit limitation. There are other ways tuple-like keys could be used with a string formatting schema.

@eslavich eslavich modified the milestones: 2.0.0, 1.6.0 Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants