[feature request] function decorator `timer` should support direct call
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 42/100
Research direction
Start at the timer decorator definition and compare how it handles @timer() with the direct @timer form shown in the issue. Confirm that both decorator usages run successfully while preserving the wrapped function behavior, then check the project's existing tests if available.
Written by the indexing model from the issue text.
Description
Currently, it can only be
@timer()
def my_func():
pass
But, the following code is expected to run but fail:
@timer
def my_func():
pass
An fix can be easily done to decorator definition by
def example2(_func=None, *, kw1=val1, kw2=val2):
if _func is None:
return functools.partials(example2, kw1=val1, kw2=kw2)
@functools.wraps(func)
def wrapper(*args, **kwargs):
# do things with kw1
return func(*args, **kwargs)
return wrapper
I am willing to make a PR if it is needed.
- Dominant language
- Python
- Stars
- 73
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from brouberol/contexttimer
-
Difficulty 1/5 Under an hour Newbie friendliness 50/100
brouberol/contexttimer#14 · 1 reaction ·
All issues in brouberol/contexttimer
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·