3
3
import inspect
4
4
from contextlib import nullcontext
5
5
6
- cb_create_call_stack_context_manager = None
7
6
cb_notify_dataframe_method_call = None
8
7
cb_notify_series_method_call = None
9
8
@@ -30,22 +29,20 @@ def __init__(self, pandas_obj):
30
29
31
30
@wraps (method )
32
31
def __call__ (self , * args , ** kwargs ):
33
- global cb_create_call_stack_context_manager
34
- with cb_create_call_stack_context_manager (method .__name__ ) if cb_create_call_stack_context_manager else nullcontext () as sc :
35
- method_call_obj = None
36
- global cb_notify_dataframe_method_call
37
- if cb_notify_dataframe_method_call :
38
- method_call_obj = cb_notify_dataframe_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
39
- if method_call_obj :
40
- new_args , new_kwargs = method_call_obj .handle_start_method_call ()
41
- args = new_args [1 :]; kwargs = new_kwargs
42
-
43
- ret = method (self ._obj , * args , ** kwargs )
44
-
32
+ method_call_obj = None
33
+ global cb_notify_dataframe_method_call
34
+ if cb_notify_dataframe_method_call :
35
+ method_call_obj = cb_notify_dataframe_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
45
36
if method_call_obj :
46
- method_call_obj .handle_end_method_call (ret )
47
-
48
- return ret
37
+ new_args , new_kwargs = method_call_obj .handle_start_method_call ()
38
+ args = new_args [1 :]; kwargs = new_kwargs
39
+
40
+ ret = method (self ._obj , * args , ** kwargs )
41
+
42
+ if method_call_obj :
43
+ method_call_obj .handle_end_method_call (ret )
44
+
45
+ return ret
49
46
50
47
register_dataframe_accessor (method .__name__ )(AccessorMethod )
51
48
@@ -68,22 +65,20 @@ def __init__(self, pandas_obj):
68
65
69
66
@wraps (method )
70
67
def __call__ (self , * args , ** kwargs ):
71
- global cb_create_call_stack_context_manager
72
- with cb_create_call_stack_context_manager (method .__name__ ) if cb_create_call_stack_context_manager else nullcontext () as sc :
73
- method_call_obj = None
74
- global cb_notify_series_method_call
75
- if cb_notify_series_method_call :
76
- method_call_obj = cb_notify_series_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
77
- if method_call_obj :
78
- new_args , new_kwargs = method_call_obj .handle_start_method_call ()
79
- args = new_args [1 :]; kwargs = new_kwargs
80
-
81
- ret = method (self ._obj , * args , ** kwargs )
82
-
68
+ method_call_obj = None
69
+ global cb_notify_series_method_call
70
+ if cb_notify_series_method_call :
71
+ method_call_obj = cb_notify_series_method_call (self ._obj , method .__name__ , method_signature , args , kwargs )
83
72
if method_call_obj :
84
- method_call_obj .handle_end_method_call (ret )
85
-
86
- return ret
73
+ new_args , new_kwargs = method_call_obj .handle_start_method_call ()
74
+ args = new_args [1 :]; kwargs = new_kwargs
75
+
76
+ ret = method (self ._obj , * args , ** kwargs )
77
+
78
+ if method_call_obj :
79
+ method_call_obj .handle_end_method_call (ret )
80
+
81
+ return ret
87
82
88
83
register_series_accessor (method .__name__ )(AccessorMethod )
89
84
0 commit comments