Skip to content

Commit e0ea9d9

Browse files
committed
a bit more formal spec on method_call_ctx_factory
1 parent d80ec75 commit e0ea9d9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

pandas_flavor/register.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@ def handle_pandas_extention_call(method, method_signature, obj, args, kwargs):
2323
to process inputs and outputs of *method* call. It is also possible that the context object method *handle_start_method_call*
2424
will modify original args and kwargs before *method* call.
2525
26-
method_call_ctx_factory function signature: (method_name: str, args: list, kwargs: dict) -> ctx object
27-
28-
ctx object should implement *with* context __enter__/__exit__ as well as methods:
29-
- handle_start_method_call(method_name: str, method_signature: inspect.Signature, args: list, kwargs: dict) -> (list, dict)
30-
- handle_end_method(obj) -> None
26+
method_call_ctx_factory function signature: (method_name: str, args: list, kwargs: dict) -> MethodCallCtx
27+
28+
MethodCallCtx is an abstract class:
29+
class MethodCallCtx(abc.ABC):
30+
@abstractmethod
31+
def __enter__(self) -> None: raise NotImplemented
32+
@abstractmethod
33+
def __exit__(self, exc_type, exc_value, traceback) -> None: raise NotImplemented
34+
@abstractmethod
35+
def handle_start_method_call(self, method_name: str, method_signature: inspect.Signature, method_args: list, method_kwargs: dict) -> tuple(list, dict): raise NotImplemented
36+
@abstractmethod
37+
def handle_end_method_call(self, ret: object) -> None: raise NotImplemented
38+
3139
3240
Parameters
3341
----------

0 commit comments

Comments
 (0)