summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2021-04-03 15:57:33 +0200
committerMichele Simionato <michele.simionato@gmail.com>2021-04-03 15:57:33 +0200
commit7fb1e34632b8f27578eb89c1c583c58b7dc74fde (patch)
tree2d4fa4b223d8db51a755ecb6df9aa645ded0810e /src
parentc12ec8557d8834e4c5c7c59b8275f3694ea6039d (diff)
downloadpython-decorator-git-7fb1e34632b8f27578eb89c1c583c58b7dc74fde.tar.gz
Fixed func.__doc__ not being copied
Diffstat (limited to 'src')
-rw-r--r--src/decorator.py17
-rw-r--r--src/tests/documentation.py4
2 files changed, 5 insertions, 16 deletions
diff --git a/src/decorator.py b/src/decorator.py
index 465558f..1cb1596 100644
--- a/src/decorator.py
+++ b/src/decorator.py
@@ -37,11 +37,10 @@ import sys
import inspect
import operator
import itertools
-import abc
from contextlib import _GeneratorContextManager
from inspect import getfullargspec, iscoroutinefunction, isgeneratorfunction
-__version__ = '5.0.3'
+__version__ = '5.0.4'
DEF = re.compile(r'\s*def\s*([_\w][_\w\d]*)\s*\(')
POS = inspect.Parameter.POSITIONAL_OR_KEYWORD
@@ -219,23 +218,11 @@ def decorate(func, caller, extras=()):
fun.__qualname__ = func.__qualname__
fun.__annotations__ = func.__annotations__
fun.__kwdefaults__ = func.__kwdefaults__
+ fun.__doc__ = func.__doc__
fun.__dict__.update(func.__dict__)
return fun
-class Decorator(metaclass=abc.ABCMeta):
- """
- Abstract base class. Subclass it and override the caller method to
- define your own decorator factories.
- """
- @abc.abstractmethod
- def caller(self, func, *args, **kw):
- pass
-
- def __call__(self, func):
- return decorate(func, self.caller)
-
-
def decorator(caller, _func=None):
"""
decorator(caller) converts a caller function into a decorator
diff --git a/src/tests/documentation.py b/src/tests/documentation.py
index 67bb44a..889f97f 100644
--- a/src/tests/documentation.py
+++ b/src/tests/documentation.py
@@ -1143,10 +1143,12 @@ and not if you pass them as keyword arguments:
```
This can be pretty confusing since non-keyword arguments are passed as
keywork arguments, but it the way it works with ``functools.wraps`` and
-the way many people expect it to work:
+the way many people expect it to work. You can play with
$$chattywrapper
+and see that we are consistent indeed.
+
In the present implementation, decorators generated by ``decorator``
can only be used on user-defined Python functions, methods or coroutines.
I have no interest in decorating generic callable objects. If you want to