Skip to content

Commit 80409af

Browse files
committed
CLN: remove util._decorators.make_signature and make related changes
1 parent d66da60 commit 80409af

File tree

3 files changed

+2
-76
lines changed

3 files changed

+2
-76
lines changed

pandas/core/groupby/base.py

+2-28
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
hold the whitelist of methods that are exposed on the
44
SeriesGroupBy and the DataFrameGroupBy objects.
55
"""
6-
7-
import types
8-
9-
from pandas.util._decorators import make_signature
10-
116
from pandas.core.dtypes.common import is_list_like, is_scalar
127

138

@@ -116,14 +111,6 @@ class where members are defined.
116111
Since we don't want to override methods explicitly defined in the
117112
base class, any such name is skipped.
118113
"""
119-
120-
method_wrapper_template = \
121-
"""def %(name)s(%(sig)s) :
122-
\"""
123-
%(doc)s
124-
\"""
125-
f = %(self)s.__getattr__('%(name)s')
126-
return f(%(args)s)"""
127114
property_wrapper_template = \
128115
"""@property
129116
def %(name)s(self) :
@@ -139,19 +126,6 @@ def %(name)s(self) :
139126
f = getattr(klass, name)
140127
doc = f.__doc__
141128
doc = doc if type(doc) == str else ''
142-
if isinstance(f, types.MethodType):
143-
wrapper_template = method_wrapper_template
144-
decl, args = make_signature(f)
145-
# pass args by name to f because otherwise
146-
# GroupBy._make_wrapper won't know whether
147-
# we passed in an axis parameter.
148-
args_by_name = ['{0}={0}'.format(arg) for arg in args[1:]]
149-
params = {'name': name,
150-
'doc': doc,
151-
'sig': ','.join(decl),
152-
'self': args[0],
153-
'args': ','.join(args_by_name)}
154-
else:
155-
wrapper_template = property_wrapper_template
156-
params = {'name': name, 'doc': doc}
129+
wrapper_template = property_wrapper_template
130+
params = {'name': name, 'doc': doc}
157131
yield wrapper_template % params

pandas/tests/util/test_util.py

-18
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
import pandas.compat as compat
77
from pandas.compat import raise_with_traceback
8-
from pandas.util._decorators import deprecate_kwarg, make_signature
9-
from pandas.util._validators import validate_kwargs
108

119
import pandas.util.testing as tm
1210

@@ -37,22 +35,6 @@ def test_numpy_err_state_is_default():
3735
assert np.geterr() == expected
3836

3937

40-
@pytest.mark.parametrize("func,expected", [
41-
# Case where the func does not have default kwargs.
42-
(validate_kwargs, (["fname", "kwargs", "compat_args"],
43-
["fname", "kwargs", "compat_args"])),
44-
45-
# Case where the func does have default kwargs.
46-
(deprecate_kwarg, (["old_arg_name", "new_arg_name",
47-
"mapping=None", "stacklevel=2"],
48-
["old_arg_name", "new_arg_name",
49-
"mapping", "stacklevel"]))
50-
])
51-
def test_make_signature(func, expected):
52-
# see gh-17608
53-
assert make_signature(func) == expected
54-
55-
5638
def test_raise_with_traceback():
5739
with pytest.raises(LookupError, match="error_text"):
5840
try:

pandas/util/_decorators.py

-30
Original file line numberDiff line numberDiff line change
@@ -319,33 +319,3 @@ def indent(text, indents=1):
319319
return ''
320320
jointext = ''.join(['\n'] + [' '] * indents)
321321
return jointext.join(text.split('\n'))
322-
323-
324-
def make_signature(func):
325-
"""
326-
Returns a tuple containing the paramenter list with defaults
327-
and parameter list.
328-
329-
Examples
330-
--------
331-
>>> def f(a, b, c=2):
332-
>>> return a * b * c
333-
>>> print(make_signature(f))
334-
(['a', 'b', 'c=2'], ['a', 'b', 'c'])
335-
"""
336-
337-
spec = inspect.getfullargspec(func)
338-
if spec.defaults is None:
339-
n_wo_defaults = len(spec.args)
340-
defaults = ('',) * n_wo_defaults
341-
else:
342-
n_wo_defaults = len(spec.args) - len(spec.defaults)
343-
defaults = ('',) * n_wo_defaults + tuple(spec.defaults)
344-
args = []
345-
for var, default in zip(spec.args, defaults):
346-
args.append(var if default == '' else var + '=' + repr(default))
347-
if spec.varargs:
348-
args.append('*' + spec.varargs)
349-
if spec.varkw:
350-
args.append('**' + spec.varkw)
351-
return args, spec.args

0 commit comments

Comments
 (0)