From bdd9f5ae30e9c3b825d024dc04c40c27193275e4 Mon Sep 17 00:00:00 2001 From: Mix Date: Sun, 7 Feb 2021 02:27:09 +0800 Subject: [PATCH] :bug: fix bad type hinting --- nonebot/plugin.py | 4 ++-- nonebot/rule.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nonebot/plugin.py b/nonebot/plugin.py index 7bb8716f..dd992f57 100644 --- a/nonebot/plugin.py +++ b/nonebot/plugin.py @@ -421,10 +421,10 @@ def on_command(cmd: Union[str, Tuple[str, ...]], """ async def _strip_cmd(bot: "Bot", event: "Event", state: T_State): - message: Iterable[MessageSegment] = event.get_message() + message = event.get_message() text_processed = False for index, segment in enumerate(message): - segment: MessageSegment = message.pop(index) + segment: "MessageSegment" = message.pop(index) if segment.is_text() and not text_processed: segment, *_ = message.__class__( str(segment)[len(state["_prefix"]["raw_command"]):].lstrip( diff --git a/nonebot/rule.py b/nonebot/rule.py index 002622a8..45146ae8 100644 --- a/nonebot/rule.py +++ b/nonebot/rule.py @@ -137,7 +137,7 @@ class TrieRule: prefix = None suffix = None message = event.get_message() - message_seg: Optional[MessageSegment] = next( + message_seg: Optional["MessageSegment"] = next( filter(lambda x: x.is_text(), message), None) if message_seg is not None: prefix = cls.prefix.longest_prefix(str(message_seg).lstrip())