-
-
Notifications
You must be signed in to change notification settings - Fork 202
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 TOML support #649
base: main
Are you sure you want to change the base?
Add TOML support #649
Conversation
- implement class TOMLFileConfigLoader - implement corresponding test case - add toml to requires list in setup.py
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 jupyter/notebook#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 |
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 |
@@ -9,6 +9,11 @@ | |||
import re | |||
import sys | |||
import json | |||
try: | |||
import toml |
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.
we should likely now prefer py3.11+ stdlib's tomllib
and fall back to tomli
@@ -108,7 +108,8 @@ | |||
] | |||
|
|||
extras_require = setuptools_args['extras_require'] = { | |||
'test': ['pytest'], | |||
'test': ['pytest', 'toml'], | |||
'with-toml': ['toml'], |
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.
would probably just add tomli ; python_version < 3.11
to install_requires
instead
return toml.load(f) | ||
|
||
def _convert_to_config(self, dictionary): | ||
if 'version' in dictionary: |
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.
i don't recall having seen version
on any of the other sources, and don't see why we'd want to add that constraint here unless it was added to all of them, which would be a major version bump
Fixes #648