Skip to content

Commit d215768

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d80ec75 commit d215768

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

pandas_flavor/register.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
method_call_ctx_factory = None
1010

11+
1112
def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
1213
"""
1314
This function is called when the user calls the registered method on pandas dataframe object.
@@ -19,7 +20,7 @@ def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
1920
In this case the implementation calls the registered method with unmodified args and kwargs and returns underlying method result.
2021
2122
b) case when *method_call_ctx_factory* is not None
22-
In this case *method_call_ctx_factory* expected to refer to the function to create the context object. The context object will be used
23+
In this case *method_call_ctx_factory* expected to refer to the function to create the context object. The context object will be used
2324
to process inputs and outputs of *method* call. It is also possible that the context object method *handle_start_method_call*
2425
will modify original args and kwargs before *method* call.
2526
@@ -31,11 +32,11 @@ def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
3132
3233
Parameters
3334
----------
34-
method :
35+
method :
3536
method object as registered by decorator register_dataframe_method (or register_series_method)
36-
method_signature :
37+
method_signature :
3738
signature of method as returned by inspect.signature
38-
obj :
39+
obj :
3940
pandas object - Dataframe or Series
4041
*args : list
4142
The arguments to pass to the registered method.
@@ -59,10 +60,7 @@ def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
5960
with method_call_ctx:
6061
if not isinstance(method_call_ctx, nullcontext):
6162
all_args = tuple([obj] + list(args))
62-
(
63-
new_args,
64-
new_kwargs,
65-
) = method_call_ctx.handle_start_method_call(
63+
(new_args, new_kwargs,) = method_call_ctx.handle_start_method_call(
6664
method.__name__, method_signature, all_args, kwargs
6765
)
6866
args = new_args[1:]
@@ -73,7 +71,8 @@ def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
7371
if not isinstance(method_call_ctx, nullcontext):
7472
method_call_ctx.handle_end_method_call(ret)
7573

76-
return ret
74+
return ret
75+
7776

7877
def register_dataframe_method(method):
7978
"""Register a function as a method attached to the Pandas DataFrame.
@@ -98,7 +97,9 @@ def __init__(self, pandas_obj):
9897

9998
@wraps(method)
10099
def __call__(self, *args, **kwargs):
101-
return handle_pandas_extention_call(method, method_signature, self._obj, args, kwargs)
100+
return handle_pandas_extention_call(
101+
method, method_signature, self._obj, args, kwargs
102+
)
102103

103104
register_dataframe_accessor(method.__name__)(AccessorMethod)
104105

@@ -121,7 +122,9 @@ def __init__(self, pandas_obj):
121122

122123
@wraps(method)
123124
def __call__(self, *args, **kwargs):
124-
return handle_pandas_extention_call(method, method_signature, self._obj, args, kwargs)
125+
return handle_pandas_extention_call(
126+
method, method_signature, self._obj, args, kwargs
127+
)
125128

126129
register_series_accessor(method.__name__)(AccessorMethod)
127130

0 commit comments

Comments
 (0)