You do not need to provide your own wrapper anymore, just use @decorator.decorator
on the inner function, which takes one extra first positional argument, the function wrapped:
@decorator.decorator
def mydec(func, cls, *args, **kwargs):
# do some stuff
return func(cls, *args, **kwargs)
The decorator
package doesn't use a closure for decorators and instead passes in the wrapped function as an argument.
Demo:
>>> @decorator.decorator
... def mydec(func, cls, *args, **kwargs):
... # do some stuff
... return func(cls, *args, **kwargs)
...
>>> class Foo(object):
... @classmethod
... @mydec
... def bar(cls, baz='test', qux=None):
... print (baz, qux)
...
>>> Foo.bar()
('test', None)