summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMichele Simionato <michele.simionato@gmail.com>2019-03-16 07:40:19 +0100
committerMichele Simionato <michele.simionato@gmail.com>2019-03-16 07:40:19 +0100
commitab1cbff0217c0f3db18b6f6a5061e8d955b5f29e (patch)
tree5b628e332c3d2dae6b833c9cae315515123b69d7 /src/tests
parente45d93fb8e802e19e2677edb46a648bcebc956ac (diff)
downloadpython-decorator-git-ab1cbff0217c0f3db18b6f6a5061e8d955b5f29e.tar.gz
Doc fixes
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/documentation.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/tests/documentation.py b/src/tests/documentation.py
index d64c683..cb6e6e4 100644
--- a/src/tests/documentation.py
+++ b/src/tests/documentation.py
@@ -125,19 +125,20 @@ can be used as a decorator. However, this definition is somewhat too large
to be really useful. It is more convenient to split the generic class of
decorators in two subclasses:
-*signature-preserving* decorators:
- Callable objects which accept a function as input and return
- a function as output, *with the same signature*.
-*signature-changing* decorators:
- Decorators which change the signature of their input function,
- or decorators that return non-callable objects.
-
-**Signature-changing** decorators have their use: for instance, the
+1. **signature-preserving decorators**, callable objects which accept
+ a function as input and return a function as output, *with the
+ same signature*
+
+2. **signature-changing** decorators, i.e. decorators
+ which change the signature of their input function, or decorators
+ that return non-callable objects
+
+Signature-changing decorators have their use: for instance, the
builtin classes ``staticmethod`` and ``classmethod`` are in this
group. They take functions and return descriptor objects which
are neither functions, nor callables.
-Still, **signature-preserving** decorators are more common, and easier
+Still, signature-preserving decorators are more common, and easier
to reason about. In particular, they can be composed together,
whereas other decorators generally cannot.
@@ -204,7 +205,7 @@ Python 3.5. This is pretty bad: ``pydoc`` will tell you that the
function accepts the generic signature ``*args, **kw``, but
calling the function with more than one argument raises an error:
-```
+```python
>>> f1(0, 1) # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
@@ -470,6 +471,8 @@ TypeError: You are decorating a non function: <class '__main__.User'>
```
+Be careful!
+
``decorator(cls)``
--------------------------------------------
@@ -1361,7 +1364,8 @@ you are unhappy with it, send me a patch!
function_annotations = """Function annotations
---------------------------------------------
-Python 3 introduced the concept of `function annotations`_: the ability
+Python 3 introduced the concept of [function annotations](
+http://www.python.org/dev/peps/pep-3107/): the ability
to annotate the signature of a function with additional information,
stored in a dictionary named ``__annotations__``. The ``decorator`` module
(starting from release 3.3) will understand and preserve these annotations.