-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
Make all (but one?) of the Parameter arguments keywords only #730
Comments
My vote goes to 2. I believe this keeps things simple. |
Edit: My vote is changed to number 1 for the same reason as @philippjfr |
I think the only way forward we have here is to move to keyword only. There's no reasonable route to standardizing on consistently making the |
I would personally be happy with option 1 and that seems like the simplest way to me as well. Option 2 is also very reasonable and may feel more natural for some users. That said, I agree with Philipp in that I only think this should be done if the semantics for a positional argument are completely clear for all parameters (which is not the case right now). |
I have opened #737 for you to see how it feels to have a warning emitted when a positional argument is passed to a Parameter. # foo.py
import param
class P(param.Parameterized):
n = param.Number(1) Output:
If we pursue with this approach, the plan I'd suggest would be to:
|
Parameters can currently be constructed with a variable number of positional arguments.
PEP 3102 implemented in Python 3.0 added support for declaring arguments that are keywords-only:
Param dates from way before this PEP was accepted and does not benefit from it, while I think it should :)
There's however a remaining question, that is about the first argument. @jbednar explained me that the spirit of the current state is that the first argument is the value that makes the most sense for the Parameter at hand. For instance, for
Number
it is thedefault
number, or forBoolean
thedefault
boolean value. In most cases,default
is indeed the first argument and can be passed by position, for exampleparam.Boolean(True)
. There are a few Parameters that don't havedefault
as their first argument:ClassSelector
hasclass_
Selector
hasobjects
. Note that its subclasses -ListSelector
,FileSelector
, andMultiFileSelector
- still havedefault
as a first argument :/ Same forObjectSelector
that is deprecated but still used a lot.Composite
hasattribs
Dynamic
actually has default as its first argument but it accepts it as keyword onlyNow there are multiple ways to approach that, all have their pros and cons, and all are more or less a breaking change:
default
default
, but can also beobjects
,class_
, ...)This is a timely question with the upcoming Param 2.0 and the Sentinel work (#605) that touched the signatures.
Will need the opinion of Param users on this one to get a feeling on what the best API could be and what the extent of the breaking change you would be willing to accept: @jlstevens, @philippjfr, @hoxbro, @MarcSkovMadsen
The text was updated successfully, but these errors were encountered: