-
-
Notifications
You must be signed in to change notification settings - Fork 204
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 a callable traitlet type #321
Comments
I actually instead solved it like jupyterhub/systemdspawner@8d9fbc8 instead, which exposed a much smaller customization surface. This helps a lot when maintaining backwards compatibility, so perhaps not having a callable is a good idea! :) |
I'd be fine adding callable. It's also achievable with Any + validation: class C(HasTraits):
f = Any()
@validate('f')
def _(self, proposal):
if not callable(proposal.value):
raise TraitError("I need a callable!")
return proposal.value |
Seems that the |
Missed in ipython#333, as noted in ipython#321 (comment). Thanks!
I added it to the docs here #523 |
This would be useful when you need to pass in a function. I've run into this several times when writing JupyterHub spawners. Environment variables can be specified as a dict whose value can be callable in JupyterHub, for example. I'm implementing this in one of my spawners just now, and think it'll be useful in the core library too.
Would people be open to a patch that added a callable traitlet type? if so, should it support further validation? The only one I could think of that'll make sense in Python would be an arity check...
The text was updated successfully, but these errors were encountered: