Skip to content
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 mechanism to specify that a parameter must be set? #1

Open
ceball opened this issue May 2, 2012 · 6 comments · Fixed by #605 · May be fixed by #724
Open

Add mechanism to specify that a parameter must be set? #1

ceball opened this issue May 2, 2012 · 6 comments · Fixed by #605 · May be fixed by #724
Labels
component: "parameterized" help me name this :) component: type/value stuff system of parameter type/value checking, inheritnace, etc etc status: discussion Discussion. Not yet a specific feature/bug. Likely to result in multiple PRs/issues. type-feature Feature request
Milestone

Comments

@ceball
Copy link
Member

ceball commented May 2, 2012

Is it possible to make a Parameter that has to be set? I.e. if not specified on instance creation, an exception will be raised?

@ceball
Copy link
Member Author

ceball commented May 2, 2012

Not currently supported directly. You could approximate it by making the default value be None and adding an explicit test to the object's constructor to raise an exception if the value is still None after the super()'s constructor is called.

@ceball ceball added the enh label May 9, 2014
@ceball ceball removed this from the Someday milestone Aug 28, 2017
@ceball ceball added status: discussion Discussion. Not yet a specific feature/bug. Likely to result in multiple PRs/issues. component: type/value stuff system of parameter type/value checking, inheritnace, etc etc component: "parameterized" help me name this :) labels Apr 13, 2020
@kcpevey kcpevey added this to the Wishlist milestone Jul 6, 2020
@MarcSkovMadsen
Copy link
Collaborator

Ahh. I'm currently very much hit by this lack of functionality in my daily work. See https://discourse.holoviz.org/t/how-to-make-parameter-values-mandatory/5124. I had forgotten about this issue. I can also see I've requested this functionality before in
#574

@philippjfr suggested on Discourse to add a required argument to Parameter.

@philippjfr philippjfr modified the milestones: Wishlist, 2.0 Mar 26, 2023
@maximlt maximlt reopened this Apr 15, 2023
@maximlt maximlt modified the milestones: 2.0, v2.x Jun 19, 2023
@LinuxIsCool
Copy link

It's not clear in this thread if the functionality has been implemented or what the api will look like.

Is there a roadmap to enable a required argument to Parameter as @MarcSkovMadsen suggests?

Thanks team, looks like an intricate part of param.

@maximlt
Copy link
Member

maximlt commented Oct 5, 2023

Hi @LinuxIsCool,

This feature hasn't yet been merged into Param and I'm not sure yet about the right API. Marc indeed opened a PR to add a required attribute to Parameter, the idea to pass a specific variable to the default value to signal it's required (e.g. Number(default=Required)) has also been in the air. Additionally what I wanted to do is to check how other similar libraries approach that (dataclass, attrs, pydantic). Generally Param should offer more options so that users don't have to override __init__ as it's prone to mistakes.

We have decided not to include this feature in Param 2.0 just for the sole purpose to reduce its scope and get it released, it's been long enough in the making!

@jbednar
Copy link
Member

jbednar commented Oct 5, 2023

Right; this feature has been waiting on 2.0 to be released so that it does not conflict with other APIs we've added, but we should be able to add this in a fast followon after 2.0 is released. We're on release candidate 6 now, I think, so very close!

@sjdemartini
Copy link

Now that 2.0 has been released and out for a while, is there any possibility this will be looked into again? Attempting to adopt Param/Panel in a project I'm using has been a bit difficult after coming from the extensive validation possibilities of Pydantic, and enforcing things like required params would help ease some of that. I saw #724, where implementation was still being discussed, and perhaps that's easier to settle after Param 2's release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: "parameterized" help me name this :) component: type/value stuff system of parameter type/value checking, inheritnace, etc etc status: discussion Discussion. Not yet a specific feature/bug. Likely to result in multiple PRs/issues. type-feature Feature request
Projects
None yet
8 participants