Observed since 20 Oct, 18:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
acls
`@cls` - Class Made Aware to Decorator
@cls - Class Made Aware to DecoratorThe purpose of this library is to provide possibility to create decorators, especially in super classes, with current class cls as argument.
Everything are centered with our new cls module, keyword, magic, or what every you think it would be.
Install by pip from PyPI:
pip install acls
A typical snippet looks like:
from functools import wraps
import cls
class Base(metaclass=cls.ClsMeta):
@cls
def decor(cls, decor_arg):
def wrap(func):
@wraps(func)
def wrapper(self):
# do something with `func`
retval = func(self)
# do something with `retval`
return retval
return wrapper
return wrap
class Extended(Base):
@cls.decor('some arg')
def func(self):
# do something
pass
The magic is that you can use @cls.decor in Extended class, which is inheritance from Base.
What is more, with in the decorator Base.decor, argument cls will be assigned with the correct current class.
In this example, it would simply be a reference to Extended.
This would be helpful if you want to make use of some class property here in the decorator.
Well, there is no magic. I created a delegator in class namespace to enable both class possible to use @cls.
So, it is not the module cls as we imported on the top.
I use this to make it more consistent looking, and fool some interpreters like pylint.
No offense, just want to make them less noisy.
Unfortunately, This work is based on customizing python class creation.
I have to make use of __prepare__, which is introduced only to python 3.
That means there is no known possible backward compatibility with python 2 now.
The code is tested against python 3.5+.
Please let me know if you come up with an idea how to manipulate class creation in python 2.
There are a couple of issues, with which I am talking. Contributions are welcome.
callable() to support optional arguments in decorator@classmethod, or many other decoratorspylint really noisyDownload counts and popularity will appear here as the collector receives them.
Declarations describe requirements; they are not a resolved dependency graph.
sdist · 4.17 KB · Python source
Shared repository data · GitHub
Public sponsor counts have not been collected. These signals belong to the repository owner.
github · 1 observations shown. Missing days are unknown.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-21 | 0 | 2026-10-21T18:41:25.6753687Z |
Observed since 20 Oct, 18:17 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:c5dc20b72d2f0a275b664fa4444d948e32b89ab3ed7c3b1938dd4faa9cc703be