client_python icon indicating copy to clipboard operation
client_python copied to clipboard

add Timer decorator support partial function

Open dafu-wu opened this issue 1 year ago • 4 comments

When we use time to decorate a partial function, I get an cannot decorate partial function error. Should we use timer to support partial functions @hynek @csmarchbanks ? I thought it should be added and tried to add the relevant code.

dafu-wu avatar Nov 21 '22 08:11 dafu-wu

Thank you for the PR! decorator.py is actually copied from an old version of https://github.com/micheles/decorator, and we do not want to manually modify the contents. I would be ok updating to a newer version of decorator if it supports partial functions.

csmarchbanks avatar Nov 23 '22 19:11 csmarchbanks

ok, I tried to submit a pr in the decorator.

dafu-wu avatar Nov 24 '22 03:11 dafu-wu

#https://github.com/micheles/decorator/pull/150

dafu-wu avatar Nov 27 '22 07:11 dafu-wu

Will this maybe as a side-effect solve issues with the decorator making an function untyped? (example attached)

mypy .
toolchain/prometheus_timetac_exporter.py:47:2: error: Untyped decorator makes function "collect_ttqueue_oldest_pending_job_timestamp" untyped  [misc]
    @METRIC_QUERY_RESULT_TIME.time()
     ^
Found 1 error in 1 file (checked 16 source files)
make: *** [lint] Error 1

Currently I've solved this via a # type: ignore directive.

GhostLyrics avatar Jan 11 '23 20:01 GhostLyrics