9
9
def deprecate (name , alternative , alt_name = None , klass = None ,
10
10
stacklevel = 2 ):
11
11
"""
12
-
13
- Return a new function that emits a deprecation warning on use
12
+ Return a new function that emits a deprecation warning on use.
14
13
15
14
Parameters
16
15
----------
@@ -22,8 +21,8 @@ def deprecate(name, alternative, alt_name=None, klass=None,
22
21
Name to use in preference of alternative.__name__
23
22
klass : Warning, default FutureWarning
24
23
stacklevel : int, default 2
25
-
26
24
"""
25
+
27
26
alt_name = alt_name or alternative .__name__
28
27
klass = klass or FutureWarning
29
28
@@ -35,7 +34,8 @@ def wrapper(*args, **kwargs):
35
34
36
35
37
36
def deprecate_kwarg (old_arg_name , new_arg_name , mapping = None , stacklevel = 2 ):
38
- """Decorator to deprecate a keyword argument of a function
37
+ """
38
+ Decorator to deprecate a keyword argument of a function.
39
39
40
40
Parameters
41
41
----------
@@ -72,8 +72,8 @@ def deprecate_kwarg(old_arg_name, new_arg_name, mapping=None, stacklevel=2):
72
72
FutureWarning: old='yes' is deprecated, use new=True instead
73
73
warnings.warn(msg, FutureWarning)
74
74
yes!
75
-
76
75
"""
76
+
77
77
if mapping is not None and not hasattr (mapping , 'get' ) and \
78
78
not callable (mapping ):
79
79
raise TypeError ("mapping from old to new argument values "
@@ -155,7 +155,12 @@ def __call__(self, func):
155
155
return func
156
156
157
157
def update (self , * args , ** kwargs ):
158
- "Assume self.params is a dict and update it with supplied args"
158
+ """
159
+ Update self.params with supplied args.
160
+
161
+ If called, we assume self.params is a dict.
162
+ """
163
+
159
164
self .params .update (* args , ** kwargs )
160
165
161
166
@classmethod
@@ -215,16 +220,16 @@ def indent(text, indents=1):
215
220
216
221
def make_signature (func ):
217
222
"""
218
- Returns a string repr of the arg list of a func call, with any defaults
223
+ Returns a string repr of the arg list of a func call, with any defaults.
219
224
220
225
Examples
221
226
--------
222
-
223
227
>>> def f(a,b,c=2) :
224
228
>>> return a*b*c
225
229
>>> print(_make_signature(f))
226
230
a,b,c=2
227
231
"""
232
+
228
233
spec = signature (func )
229
234
if spec .defaults is None :
230
235
n_wo_defaults = len (spec .args )
@@ -244,8 +249,8 @@ def make_signature(func):
244
249
245
250
class docstring_wrapper (object ):
246
251
"""
247
- decorator to wrap a function,
248
- provide a dynamically evaluated doc-string
252
+ Decorator to wrap a function and provide
253
+ a dynamically evaluated doc-string.
249
254
250
255
Parameters
251
256
----------
0 commit comments