|
9 | 9 | method_call_ctx_factory = None
|
10 | 10 |
|
11 | 11 |
|
12 |
| -def handle_pandas_extention_call(method, method_signature, obj, args, kwargs): |
| 12 | +def handle_pandas_extension_call(method, method_signature, obj, args, kwargs): |
13 | 13 | """
|
14 |
| - This function is called when the user calls the registered method on pandas dataframe object. |
15 |
| - pandas extention mechanism passes args and kwargs of original method call as it was applied to obj |
| 14 | + This function is called when the user calls a pandas DataFrame object's method. |
| 15 | + The pandas extension mechanism passes args and kwargs of original method call as it is applied to obj |
16 | 16 |
|
17 |
| - Implementation uses global var *method_call_ctx_factory" |
| 17 | + Our implementation uses the global variable `method_call_ctx_factory`. |
18 | 18 |
|
19 |
| - a) case when *method_call_ctx_factory* is None |
20 |
| - In this case the implementation calls the registered method with unmodified args and kwargs and returns underlying method result. |
| 19 | + `method_call_ctx_factory` can be either None or an abstract class. |
21 | 20 |
|
22 |
| - b) case when *method_call_ctx_factory* is not None |
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 |
24 |
| - to process inputs and outputs of *method* call. It is also possible that the context object method *handle_start_method_call* |
25 |
| - will modify original args and kwargs before *method* call. |
| 21 | + When `method_call_ctx_factory` is None, the implementation calls the registered method with unmodified args and kwargs and returns underlying method result. |
| 22 | +
|
| 23 | + When `method_call_ctx_factory` is not None, `method_call_ctx_factory` is expected to refer to the function to create the context object. |
| 24 | + The context object will be used to process inputs and outputs of `method` calls. |
| 25 | + It is also possible that the context object method `handle_start_method_call` |
| 26 | + will modify original args and kwargs before `method` call. |
| 27 | +
|
| 28 | + `method_call_ctx_factory` is a function that should have the following signature: |
| 29 | + |
| 30 | + `f(method_name: str, args: list, kwargs: dict) -> MethodCallCtx` |
26 | 31 |
|
27 |
| - method_call_ctx_factory function signature: (method_name: str, args: list, kwargs: dict) -> MethodCallCtx |
28 | 32 |
|
29 | 33 | MethodCallCtx is an abstract class:
|
30 | 34 | class MethodCallCtx(abc.ABC):
|
| 35 | +
|
31 | 36 | @abstractmethod
|
32 |
| - def __enter__(self) -> None: raise NotImplemented |
| 37 | + def __enter__(self) -> None: |
| 38 | + raise NotImplemented |
| 39 | +
|
33 | 40 | @abstractmethod
|
34 |
| - def __exit__(self, exc_type, exc_value, traceback) -> None: raise NotImplemented |
| 41 | + def __exit__(self, exc_type, exc_value, traceback) -> None: |
| 42 | + raise NotImplemented |
| 43 | +
|
35 | 44 | @abstractmethod
|
36 |
| - def handle_start_method_call(self, method_name: str, method_signature: inspect.Signature, method_args: list, method_kwargs: dict) -> tuple(list, dict): raise NotImplemented |
| 45 | + def handle_start_method_call(self, method_name: str, method_signature: inspect.Signature, method_args: list, method_kwargs: dict) -> tuple(list, dict): |
| 46 | + raise NotImplemented |
| 47 | +
|
37 | 48 | @abstractmethod
|
38 |
| - def handle_end_method_call(self, ret: object) -> None: raise NotImplemented |
| 49 | + def handle_end_method_call(self, ret: object) -> None: |
| 50 | + raise NotImplemented |
39 | 51 |
|
40 | 52 |
|
41 | 53 | Parameters
|
|
0 commit comments