peru icon indicating copy to clipboard operation
peru copied to clipboard

consider validating our markup with Schema

Open oconnor663 opened this issue 9 years ago • 3 comments

https://github.com/halst/schema Same guy who wrote Docopt.

Others: https://github.com/alecthomas/voluptuous https://github.com/Julian/jsonschema https://github.com/podio/valideer

oconnor663 avatar Aug 19 '14 02:08 oconnor663

I just played with this for an hour. It works, but I'm not sure it really results in less code, once you add in good error messages for all the cases. I'm worried it's actually harder to read than regular python. There are also some difficulties like, can you automatically parse out Module objects when the name is a key and the contents are a value? Probably not, so there would still need to be some custom parsing logic after everything's been validated. Closing for now.

oconnor663 avatar Feb 02 '15 17:02 oconnor663

#96 raises an example where Schema might've helped by actually typechecking all the values that we parse. It might be worth having even in addition to our existing parser.

oconnor663 avatar Mar 05 '15 00:03 oconnor663

Rather than using a Python-specific library, it might be a good idea to use a more generic schema format, like JSON Schema, that lets us express our schemas as data rather than code. There seems to be a good Python implementation.

oconnor663 avatar Apr 14 '15 18:04 oconnor663