-
Notifications
You must be signed in to change notification settings - Fork 25
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 Ast match of None value params #25
base: master
Are you sure you want to change the base?
Conversation
The reason it doesn't recognise None is that there's a loose expectation that you replace parameters with the same type, and you can use the type to make simple decisions about how to get input - e.g. a spin box for an integer, or a checkbox for a boolean. This also encourages working with realistic defaults and running the notebook interactively. But that's only a loose guideline, not a strict rule. I'm open to thinking differently about it. Can you say a bit about why you want to use None? |
I see. It makes sense to not accept None value if there is such expectation.
In my scenario, I have multiple runner environments of a single notebook file. The parameters are to configure how the notebook should behaviour differently. One param of them by default is None (running in local), but not None in other environments (maybe jupyterlab/ k8s). However, since the None params is excluded, the notebook is not executable in other environments.
IMO, it is user's own practice to either prevent using None value as parameters or not. |
or in other words, I would see |
Sorry it's taken me so long to respond again.
With #19 now merged, your Is that OK? Or would it work to have a default value of the same type as the real value when the parameter is not meaningful? Like 0, -1 or I'm still reluctant to recognise None as a parameter, because having a type with parameters means you can do things like building a form for them: nbparameterise/examples/htmlform.py Lines 37 to 52 in d8741ed
Or use them to validate command-line arguments, as in nbclick. This has got more complicated now that you can have lists and dicts as parameters, and we don't require them to be e.g. list-of-str. But it still seems like a useful idea for many purposes to have some simple types, so I'd rather not encourage people to use I guess type hints shift this a bit. We could e.g. recognise |
None
value parameters are ignored inextract_parameters
since there are no AST match rule of it.This PR adds the support on
None
value parameters.