Skip to content

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented May 23, 2023

This fix still allows depending on attributes of a Parameterized that are themselves Parameterized but are not declared as a parameter. Since some people are relying on this I did not want to remove that behavior. The actual bug that caused #635 was that if you depended on an attribute that was Parameterized it would treat it as if it was an undecorated method declaration, which are treated as if they depend on all parameters, i.e.:

class Sub(param.Parameterized):
    s = param.String()

class P(param.Parameterized):
    test_param = param.Parameter()

    def __init__(self, **params):
        self._sub = Sub()
        super().__init__(**params)

    @param.depends('_sub.s', watch=True)
    def cb(self):
        print('cb called')

was functionality treated very similarly to this:

class P(param.Parameterized):
    test_param = param.Parameter()

    def test(self):
        pass

    @param.depends('test', watch=True)
    def cb(self):
        print('cb called')

and since test does not declare dependencies that means cb will end up watching name and test_param.

Fixes #635

@maximlt
Copy link
Member

maximlt commented May 23, 2023

Great thanks for the quick fix! I added a test. Merging!

@maximlt maximlt merged commit ddedb65 into main May 23, 2023
@maximlt maximlt deleted the sub_object_resolve branch May 23, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Callback triggered when depending on a subobject not declared
2 participants