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
https://www.dash-extensions.com/
MIT License
417 stars 59 forks source link

Recursion for resolving callbacks #283

Open mhalaida opened 1 year ago

mhalaida commented 1 year ago

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?

joonh-min commented 5 months ago

@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.