peru
peru copied to clipboard
consider validating our markup with Schema
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
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.
#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.
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.