Skip to content

Commit 40485ec

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/pyjviz-callbacks' into pyjviz-callbacks
2 parents e0ea9d9 + d215768 commit 40485ec

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
@@ -39,11 +40,11 @@ def handle_end_method_call(self, ret: object) -> None: raise NotImplemented
3940
4041
Parameters
4142
----------
42-
method :
43+
method :
4344
method object as registered by decorator register_dataframe_method (or register_series_method)
44-
method_signature :
45+
method_signature :
4546
signature of method as returned by inspect.signature
46-
obj :
47+
obj :
4748
pandas object - Dataframe or Series
4849
*args : list
4950
The arguments to pass to the registered method.
@@ -67,10 +68,7 @@ def handle_end_method_call(self, ret: object) -> None: raise NotImplemented
6768
with method_call_ctx:
6869
if not isinstance(method_call_ctx, nullcontext):
6970
all_args = tuple([obj] + list(args))
70-
(
71-
new_args,
72-
new_kwargs,
73-
) = method_call_ctx.handle_start_method_call(
71+
(new_args, new_kwargs,) = method_call_ctx.handle_start_method_call(
7472
method.__name__, method_signature, all_args, kwargs
7573
)
7674
args = new_args[1:]
@@ -81,7 +79,8 @@ def handle_end_method_call(self, ret: object) -> None: raise NotImplemented
8179
if not isinstance(method_call_ctx, nullcontext):
8280
method_call_ctx.handle_end_method_call(ret)
8381

84-
return ret
82+
return ret
83+
8584

8685
def register_dataframe_method(method):
8786
"""Register a function as a method attached to the Pandas DataFrame.
@@ -106,7 +105,9 @@ def __init__(self, pandas_obj):
106105

107106
@wraps(method)
108107
def __call__(self, *args, **kwargs):
109-
return handle_pandas_extention_call(method, method_signature, self._obj, args, kwargs)
108+
return handle_pandas_extention_call(
109+
method, method_signature, self._obj, args, kwargs
110+
)
110111

111112
register_dataframe_accessor(method.__name__)(AccessorMethod)
112113

@@ -129,7 +130,9 @@ def __init__(self, pandas_obj):
129130

130131
@wraps(method)
131132
def __call__(self, *args, **kwargs):
132-
return handle_pandas_extention_call(method, method_signature, self._obj, args, kwargs)
133+
return handle_pandas_extention_call(
134+
method, method_signature, self._obj, args, kwargs
135+
)
133136

134137
register_series_accessor(method.__name__)(AccessorMethod)
135138

0 commit comments

Comments
 (0)