Add TOML support
- implement class TOMLFileConfigLoader
- implement corresponding test case
- add toml to requires list in setup.py
Fixes #648
Looks like the failed tests are unrelated to your changes. There's another PR with just doc enhancements that fails too.
can it be related to https://github.com/jupyter/notebook/pull/5986?
It's great to see an addition of a format for traitlets, but I think it would make more sense to not make it a hard dependency. TOMLFileConfigLoader could wrap the currently top-level "import toml" in a try-except to not force the installation of toml for anyone who won't be using that feature, but giving a helpful error message for those wanting to use it to install toml.
@rmorshea @ivanov I've closed/reopened this PR to trigger build on GH-Actions. Tests are green now on GH.
Probably the next step would be to determine offer @mexanick some guidance to avoid the hard dependency.
I have added the optional import of toml. The only thing which is suboptimal now is the testing of optional dependency (it is a bit ugly). I'd appreciate if someone has a better idea of testing implementation (or suggestion on optional dependcy incorporation)
Normally in these situations, I try to isolate this sort of "environment dependent code" in its own module so you don't have to do any try/except handling. Then, when the user tries to import it, if they haven't installed toml, they get an import error complaining that import toml failed. Thus, if no-one else has objections, my suggestions would be to add a new traitlets.config.toml_loader module containing the TOMLFileConfigLoader. This would set a precedent for future modules of the form {format}_loader. For example, if one wanted a YAML config loader, you'd create an isolated yaml_loader module since that would require the user to have yaml installed.