emilhe / dash-extensions

The dash-extensions package is a collection of utility functions, syntax extensions, and Dash components that aim to improve the Dash development experience

Home Page:https://www.dash-extensions.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recursion for resolving callbacks

mhalaida opened this issue · comments

I'm trying to extend my callbacks with a custom decorator for error handling & logging:

@callback(
    ...outputs
    ...inputs
)
@logging_decorator
def update_graph()
    ...

This works okay with native dash callbacks, but does not with dash-extensions callbacks, I assume dash-extensions resolves them differently. The error trace leads to line 1049 in enrich.py, I see there's a comment:

#Replace args and kwargs. # TODO: Is recursion needed?

Could this be related to how custom decorators are treated? If so, do you think this is something that could be addressed?

@mhalaida replacing 1041 with

        if (cbf:=callback.f) and hasattr(cbf, "__wrapped__"):
            full_arg_spec = inspect.getfullargspec(cbf.__wrapped__)
        else:
            full_arg_spec = inspect.getfullargspec(cbf)

fixed it for me.