traitlets
traitlets copied to clipboard
Make `c.` optional in config file ?
Or at least gracefully warn if missing, but still work ? Better than "Undefined variable Foo
" maybe
That would require changing the __main__
namespace and overwrite __setattr__
to accept anything that start with an uppercase, and set it on the c
object.
We could probably warn (did you forget c.
) ? Or just make c.
optional.
Thoughts ?
That would be nifty, but I'm not sure how it could work. I don't know how to handle things like import statements, or other variables in the config file that aren't part of the config itself.
Take the common example:
import netifaces
docker_ip = netifaces.ifaddresses('docker0')[netifaces.AF_INET][0]['addr']
c.JupyterHub.hub_ip = docker_ip
How do you ensure that netifaces
and docker_ip
don't end up in the config object?
@minrk, only variables that were actual traits would get assigned because of this line. We also warn on everything that isn't assigned, but that could be overcome by using two configs and seeing if the one used for c.
was empty or not.
However a user would have to be sure they didn't assign to a variable which also happens to be a trait name... It's a cool idea, but I have a feeling it's prone to a lot of frustrating user errors.
Yeah, i'm starting to be less and less convinced about my own idea, so tagging as unsure. I doubt it is worth the effort, but I'll leave that open just in case.