buildinspace / peru

a generic package manager, for including other people's code in your projects
MIT License
1.11k stars 69 forks source link

consider validating our markup with Schema #40

Open oconnor663 opened 10 years ago

oconnor663 commented 10 years ago

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 commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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.