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
Add dict config #79
Add dict config #79
Conversation
6db284b
to
5640a12
Compare
Ahhh... The current version of volutpuous does not support Python-2.6. It looks like only a few minor fixes to voluptuous would be required to make that work but I don't know if they'd take those patches. I've submitted a bug report to ask them if they would be willing to continue 2.6 support or not. If they answer in the negative I'll take a look at how hard it would be to do the schema validation in custom code rather than using voluptuous (something we may have to do someday anyway if twiggy makes it into the standard library.) |
Voluptuous issue asking whether they'd consider restoring python-2.6 support: alecthomas/voluptuous#306 |
8ea7ba7
to
067f96d
Compare
Okay, I've gotten the code switched from validating the config schema via voluptuous to validating via a bespoke validation function and updated the unit tests. init and the new code in lib/validators is 100% unittested. Test failure is due to documentation errors. The new section for dict_config() is still being worked on so that's expected. Hopefully I can get that cleaned up the rest of the way this week. |
ca0aebd
to
1c923d5
Compare
1c923d5
to
3897178
Compare
Okay, the documentation could probably use some further work (wordsmithing, organization, etc) but this is ready for someone else to review and tell me what is still lacking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, see one note about raising errors on bad dict_config. Will review docs in more depth & tweak a bit. Thanks, this is exciting.
twiggy/__init__.py
Outdated
""" | ||
try: | ||
cfg = _validate_config(config) | ||
except ValueError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think in this case it makes sense to raise... There is no validation for programmatic setup (since there's no clear 'done' state at which to check) so it falls back to internal errors at runtime, but that would be really surprising behavior here IMO
This is inspired by
dictConfig
from the python stdlib's logging module, version 2.7 and above: https://docs.python.org/2/library/logging.config.html#dictionary-schema-detailsThe idea is to make it easy to configure the logging subsystem from a config source outside of the program. That way a program can make it possible for the user to configure logging in a config file.
This PR curently has code and tests but no documentation.
Fixes #59