import{_ as i,c as a,ae as n,o as l}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"utils","description":"","frontmatter":{"title":"utils","order":100},"headers":[],"relativePath":"en/dev/api/plugin/func_call/utils.md","filePath":"en/dev/api/plugin/func_call/utils.md","lastUpdated":null}'),t={name:"en/dev/api/plugin/func_call/utils.md"};function e(p,s,h,k,r,o){return l(),a("div",null,s[0]||(s[0]=[n(`

Module nonebot_plugin_marshoai.plugin.func_call.utils


func copy_signature(func: F) -> Callable[[Callable[..., Any]], F]

Description: 复制函数签名和文档字符串的装饰器

Source code or View on GitHub
python
def copy_signature(func: F) -> Callable[[Callable[..., Any]], F]:

    def decorator(wrapper: Callable[..., Any]) -> F:

        @wraps(func)
        def wrapped(*args: Any, **kwargs: Any) -> Any:
            return wrapper(*args, **kwargs)
        return wrapped
    return decorator

func async_wrap(func: F) -> F

Description: 装饰器,将同步函数包装为异步函数

Arguments:

Return: F: 包装后的函数对象

Source code or View on GitHub
python
def async_wrap(func: F) -> F:

    @wraps(func)
    async def wrapper(*args: Any, **kwargs: Any) -> Any:
        return func(*args, **kwargs)
    return wrapper

func is_coroutine_callable(call: Callable[..., Any]) -> bool

Description: 判断是否为async def 函数 请注意:是否为 async def 函数与该函数是否能被await调用是两个不同的概念,具体取决于函数返回值是否为awaitable对象

Arguments:

Return: bool: 是否为async def函数

Source code or View on GitHub
python
def is_coroutine_callable(call: Callable[..., Any]) -> bool:
    if inspect.isroutine(call):
        return inspect.iscoroutinefunction(call)
    if inspect.isclass(call):
        return False
    func_ = getattr(call, '__call__', None)
    return inspect.iscoroutinefunction(func_)
`,19)]))}const d=i(t,[["render",e]]);export{g as __pageData,d as default};