mirror of
https://github.com/Steffo99/async-chain.git
synced 2024-11-21 20:44:21 +00:00
21 lines
489 B
Python
21 lines
489 B
Python
import functools
|
|
import typing as t
|
|
from .chain import ChainStart
|
|
|
|
|
|
class FunctionWrapper:
|
|
def __init__(self, func):
|
|
self._func = func
|
|
|
|
def __repr__(self) -> str:
|
|
return self._func.__name__
|
|
|
|
def __call__(self, *args, **kwargs) -> t.Any:
|
|
return self._func(*args, **kwargs)
|
|
|
|
|
|
def method_deco(func):
|
|
@functools.wraps(func)
|
|
def decorated(*args, **kwargs):
|
|
return ChainStart(start=FunctionWrapper(func))(*args, **kwargs)
|
|
return decorated
|