Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Timer decorator support partial function #858

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dafu-wu
Copy link

@dafu-wu dafu-wu commented Nov 21, 2022

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 dafu-wu force-pushed the master branch 2 times, most recently from 2496d0e to 7476158 Compare November 21, 2022 09:02
@csmarchbanks
Copy link
Member

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.

@dafu-wu
Copy link
Author

dafu-wu commented Nov 24, 2022

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

@dafu-wu
Copy link
Author

dafu-wu commented Nov 27, 2022

#micheles/decorator#150

@GhostLyrics
Copy link

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.

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.

3 participants