-
-
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
Validate dependencies in constructor #813
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the error is not raised at class creation time but on instantiation and only when watch=True
, it's a big improvement anyway.
It cannot be done at class creation time because the class cannot know what happens in the constructor before super is called. |
Is it because we allow people depending on objects that aren't declared as A recent change made this fail when import param
class P(param.Parameterized):
x = param.Parameter()
@param.depends('y')
def debug(self): pass Traceback:
|
I'm a little on the fence on it and likely have to revert your change. I've seen many people use the pattern and I have also used it on occasion because declaring parameters is sometimes awkward, e.g. often I use parameters for public API declarations but internally I want to be able to set up dependencies on static attributes and not have to set up parameter declarations. |
Yes that's a weakness of Param that has no way to tell whether a parameter is an input or some state you compute later on. Param has |
The dynamic resolution of dependencies loosened the validation for dependencies. However this was only intended to allow dynamic dependency resolution of the leafs or branches of nested dependencies, i.e. the root of a nested dependency has to be declared. This adds validation to ensure that the root dependency can be resolved and adds an error otherwise.