Skip to content

Commit 22fcf43

Browse files
DOC/DEPR: ensure that @deprecated functions have correct docstring (pandas-dev#18215)
1 parent 69472f9 commit 22fcf43

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1361,13 +1361,13 @@ def idxmax(self, axis=None, skipna=True, *args, **kwargs):
13611361

13621362
# ndarray compat
13631363
argmin = deprecate('argmin', idxmin,
1364-
msg="'argmin' is deprecated. Use 'idxmin' instead. "
1364+
msg="'argmin' is deprecated, use 'idxmin' instead. "
13651365
"The behavior of 'argmin' will be corrected to "
13661366
"return the positional minimum in the future. "
13671367
"Use 'series.values.argmin' to get the position of "
13681368
"the minimum now.")
13691369
argmax = deprecate('argmax', idxmax,
1370-
msg="'argmax' is deprecated. Use 'idxmax' instead. "
1370+
msg="'argmax' is deprecated, use 'idxmax' instead. "
13711371
"The behavior of 'argmax' will be corrected to "
13721372
"return the positional maximum in the future. "
13731373
"Use 'series.values.argmax' to get the position of "

pandas/util/_decorators.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import inspect
44
import types
55
import warnings
6-
from textwrap import dedent
6+
from textwrap import dedent, wrap
77
from functools import wraps, update_wrapper
88

99

@@ -29,11 +29,16 @@ def deprecate(name, alternative, alt_name=None, klass=None,
2929

3030
alt_name = alt_name or alternative.__name__
3131
klass = klass or FutureWarning
32-
msg = msg or "{} is deprecated. Use {} instead".format(name, alt_name)
32+
msg = msg or "{} is deprecated, use {} instead".format(name, alt_name)
3333

34+
@wraps(alternative)
3435
def wrapper(*args, **kwargs):
3536
warnings.warn(msg, klass, stacklevel=stacklevel)
3637
return alternative(*args, **kwargs)
38+
39+
if getattr(wrapper, '__doc__', None) is not None:
40+
wrapper.__doc__ = ('\n'.join(wrap(msg, 70)) + '\n'
41+
+ dedent(wrapper.__doc__))
3742
return wrapper
3843

3944

0 commit comments

Comments
 (0)