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

模块 nonebot_plugin_marshoai.plugin.func_call.utils


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

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

源代码在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

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

参数:

返回: F: 包装后的函数对象

源代码在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

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

参数:

返回: bool: 是否为async def函数

源代码在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};