def depends(func, *dependencies, **kw):
    """
    Annotates a Parameterized method to express its dependencies.
    The specified dependencies can be either be Parameters of this
    class, or Parameters of subobjects (Parameterized objects that
    are values of this object's parameters).  Dependencies can either
    be on Parameter values, or on other metadata about the Parameter.
    """

    # python3 would allow kw-only args
    # (i.e. "func,*dependencies,watch=False" rather than **kw and the check below)
    watch = kw.pop("watch",False)
    assert len(kw)==0, "@depends accepts only 'watch' kw"

    # TODO: rename dinfo
    _dinfo = getattr(func, '_dinfo', {})
    _dinfo.update({'dependencies': dependencies,
                   'watch': watch})

    @wraps(func)
    def _depends(*args,**kw):
        return func(*args,**kw)

    # storing here risks it being tricky to find if other libraries
    # mess around with methods
    _depends._dinfo = _dinfo

    return _depends
def depends ( func , * dependencies , ** kw ) : watch = kw . pop ( "watch" , False ) assert len ( kw ) == 0 , "@depends accepts only 'watch' kw" _dinfo = getattr ( func , '_dinfo' , { } ) _dinfo . update ( { 'dependencies' : dependencies , 'watch' : watch } ) @ wraps ( func ) def _depends ( * args , ** kw ) : return func ( * args , ** kw ) _depends . _dinfo = _dinfo return _depends
Annotates a Parameterized method to express its dependencies.
    The specified dependencies can be either be Parameters of this
    class, or Parameters of subobjects (Parameterized objects that
    are values of this object's parameters).  Dependencies can either
    be on Parameter values, or on other metadata about the Parameter.