brouberol / brouberol/contexttimer
[feature request] function decorator `timer` should support direct call
Open
- Dominant language
- Python
- Stars
- 73
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.