diff --git a/nonebot/adapters/_base.py b/nonebot/adapters/_base.py index dc2d663a..8f4c2898 100644 --- a/nonebot/adapters/_base.py +++ b/nonebot/adapters/_base.py @@ -109,7 +109,7 @@ class Bot(abc.ABC): raise NotImplementedError @abc.abstractmethod - async def call_api(self, api: str, **data): + async def call_api(self, api: str, **data) -> Any: """ :说明: @@ -130,8 +130,9 @@ class Bot(abc.ABC): raise NotImplementedError @abc.abstractmethod - async def send(self, event: "Event", - message: Union[str, "Message", "MessageSegment"], **kwargs): + async def send(self, event: "Event", message: Union[str, "Message", + "MessageSegment"], + **kwargs) -> Any: """ :说明: diff --git a/nonebot/matcher.py b/nonebot/matcher.py index b3206e1a..61ab40ae 100644 --- a/nonebot/matcher.py +++ b/nonebot/matcher.py @@ -9,14 +9,17 @@ from functools import wraps from datetime import datetime from contextvars import ContextVar from collections import defaultdict -from typing import Type, List, Dict, Union, Mapping, Iterable, Callable, Optional, NoReturn, TYPE_CHECKING +from typing import (Any, Type, List, Dict, Union, Mapping, Iterable, Callable, + Optional, NoReturn, TYPE_CHECKING) from nonebot.rule import Rule from nonebot.log import logger from nonebot.handler import Handler from nonebot.permission import Permission, USER -from nonebot.typing import T_State, T_StateFactory, T_Handler, T_ArgsParser, T_TypeUpdater, T_PermissionUpdater -from nonebot.exception import PausedException, RejectedException, FinishedException, StopPropagation +from nonebot.typing import (T_State, T_StateFactory, T_Handler, T_ArgsParser, + T_TypeUpdater, T_PermissionUpdater) +from nonebot.exception import (PausedException, RejectedException, + FinishedException, StopPropagation) if TYPE_CHECKING: from nonebot.adapters import Bot, Event, Message, MessageSegment @@ -437,7 +440,7 @@ class Matcher(metaclass=MatcherMeta): @classmethod async def send(cls, message: Union[str, "Message", "MessageSegment"], - **kwargs): + **kwargs) -> Any: """ :说明: @@ -448,9 +451,9 @@ class Matcher(metaclass=MatcherMeta): * ``message: Union[str, Message, MessageSegment]``: 消息内容 * ``**kwargs``: 其他传递给 ``bot.send`` 的参数,请参考对应 adapter 的 bot 对象 api """ - bot = current_bot.get() + bot: "Bot" = current_bot.get() event = current_event.get() - await bot.send(event=event, message=message, **kwargs) + return await bot.send(event=event, message=message, **kwargs) @classmethod async def finish(cls,