Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a1dc52

Browse files
committed
ENH docstring is now PEP8
1 parent 954b752 commit 4a1dc52

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lib/matplotlib/docstring.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import types
55

6+
67
class Substitution(object):
78
"""
89
A decorator to take a function's docstring and perform string
@@ -32,7 +33,8 @@ def some_function(x):
3233
"%s %s wrote the Raven"
3334
"""
3435
def __init__(self, *args, **kwargs):
35-
assert not (args and kwargs), "Only positional or keyword args are allowed"
36+
assert (not (args and kwargs),
37+
"Only positional or keyword args are allowed")
3638
self.params = args or kwargs
3739

3840
def __call__(self, func):
@@ -46,15 +48,16 @@ def update(self, *args, **kwargs):
4648
@classmethod
4749
def from_params(cls, params):
4850
"""
49-
In the case where the params is a mutable sequence (list or dictionary)
50-
and it may change before this class is called, one may explicitly use
51-
a reference to the params rather than using *args or **kwargs which will
52-
copy the values and not reference them.
51+
In the case where the params is a mutable sequence (list or
52+
dictionary) and it may change before this class is called, one may
53+
explicitly use a reference to the params rather than using *args or
54+
**kwargs which will copy the values and not reference them.
5355
"""
5456
result = cls()
5557
result.params = params
5658
return result
5759

60+
5861
class Appender(object):
5962
"""
6063
A function decorator that will append an addendum to the docstring
@@ -83,11 +86,13 @@ def __call__(self, func):
8386
func.__doc__ = func.__doc__ and ''.join(docitems)
8487
return func
8588

89+
8690
def dedent(func):
8791
"Dedent a docstring (if present)"
8892
func.__doc__ = func.__doc__ and cbook.dedent(func.__doc__)
8993
return func
9094

95+
9196
def copy(source):
9297
"Copy a docstring from another source function (if present)"
9398
def do_copy(target):
@@ -100,13 +105,15 @@ def do_copy(target):
100105
# is reused throughout matplotlib
101106
interpd = Substitution()
102107

108+
103109
def dedent_interpd(func):
104110
"""A special case of the interpd that first performs a dedent on
105111
the incoming docstring"""
106112
if isinstance(func, types.MethodType) and sys.version_info[0] < 3:
107113
func = func.im_func
108114
return interpd(dedent(func))
109115

116+
110117
def copy_dedent(source):
111118
"""A decorator that will copy the docstring from the source and
112119
then dedent it"""

0 commit comments

Comments
 (0)