Comments (8)
The documentation is correct, it is saying that you cannot decorate a staticmethod, meaning that dec(staticmethod(func_or_coro))
is not working. It is implicit that
staticmethod(dec(func_or_coro))
works since there is nothing strange there.
from decorator.
The trick with staticmethod/classmethod is that the decorator module works only if you use the right order, which is the one you are using. The opposite order will not work:
@log_start_stop
@staticmethod
async def make_task(n):
For me this is a non-problem, of course the right order if the first one, because the decorator has to be applied to the function not to the staticmethod. With wrapt it would work in both orders.
from decorator.
The trick with staticmethod/classmethod is that the decorator module works only if you use the right order, which is the one you are using. The opposite order will not work:
@log_start_stop @staticmethod async def make_task(n):For me this is a non-problem, of course the right order if the first one, because the decorator has to be applied to the function not to the staticmethod. With wrapt it would work in both orders.
But it doesn't support coroutine.😢
from decorator.
I am right in understanding that you are happy with the current behavior and I can close issue?
If you have a problem please be more explicit.
from decorator.
I am right in understanding that you are happy with the current behavior and I can close issue?
If you have a problem please be more explicit.
Yeah, you can close this. But would you like to add something about this to documentation?
from decorator.
I will change it is cleaner and safer to decorate only functions
-> it is cleaner and safer to decorate only functions and coroutines
.
from decorator.
And how about change If you want to decorate things like classmethods/staticmethods and general callables - which I will never support in the decorator module - I suggest you to look at the wrapt project by Graeme Dumpleton.
to If you want to decorate things like classmethods/staticmethods and general callables - which I will never support in the decorator module - I suggest you to look at the wrapt project by Graeme Dumpleton. But you can use the decorator module on these things carefully right now and it should work.
?
from decorator.
The documentation is correct, it is saying that you cannot decorate a staticmethod, meaning that
dec(staticmethod(func_or_coro))
is not working. It is implicit that
staticmethod(dec(func_or_coro))
works since there is nothing strange there.
Got it. Sorry for my poor English, I misunderstood the documentation.
from decorator.
Related Issues (20)
- pylint warning W1113: keyword-arg-before-vararg HOT 1
- Regression in 5.1.0 - decorator.contextmanager no longer compat with contextlib.contextmanager HOT 4
- `FunctionMaker.create()` fails when given a function definition with a return type annotation. HOT 1
- Functionmaker.create (from doc example) fails with kwarg-only functions HOT 6
- `FunctionMaker.create` raises unexpected SyntaxError when return is present as substring for async function
- How to make `@decorator` with other decorators? HOT 3
- TypeError: missing 1 required positional argument HOT 1
- <=3.4.2 can't be installed with modern setuptools HOT 2
- Continuous fuzzing by way of OSS-Fuzz
- compatibility issue with kwargs HOT 2
- Not preserving low level signature metadada HOT 1
- decorator whether to support decorator partial functions?
- Confusion about license using HOT 1
- Making __name__ optional attribute of decorated-function if underlying function is missing it. HOT 3
- Compatibility with Python 3.12 - RuntimeError: There is no current event loop in thread 'MainThread'.
- Unable to pull 4.4.2 from the repo only pulls in 4.2.1 HOT 1
- [BUG] kwargs are not respected HOT 3
- Create SECURITY.md
- Create a decorator for both sync and async function HOT 1
- Erroneous `%` ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decorator.