diff --git a/nonebot/adapters/_base.py b/nonebot/adapters/_base.py index c4846088..c2bf5062 100644 --- a/nonebot/adapters/_base.py +++ b/nonebot/adapters/_base.py @@ -251,8 +251,8 @@ class MessageSegment(Mapping, abc.ABC, Generic[T_Message]): - 说明: 消息段数据 """ - @abc.abstractmethod @classmethod + @abc.abstractmethod def get_message_class(cls) -> Type[T_Message]: raise NotImplementedError @@ -330,8 +330,8 @@ class Message(List[T_MessageSegment], abc.ABC): else: self.extend(self._construct(message)) - @abc.abstractmethod @classmethod + @abc.abstractmethod def get_segment_class(cls) -> Type[T_MessageSegment]: raise NotImplementedError diff --git a/nonebot/plugin/manager.py b/nonebot/plugin/manager.py index 51091274..7b9026ca 100644 --- a/nonebot/plugin/manager.py +++ b/nonebot/plugin/manager.py @@ -93,7 +93,7 @@ class PluginManager: if not prefix.startswith(_internal_space.__name__): prefix = _internal_space.__name__ module = _InternalModule(prefix, self) - sys.modules[module.__name__] = module + sys.modules[module.__name__] = module # type: ignore setattr(_internal_space, internal_id, module) return module @@ -177,11 +177,11 @@ class PluginFinder(MetaPathFinder): newname = manager._rewrite_module_name(fullname) if newname: spec = PathFinder.find_spec( - newname, [*manager.search_path, *(path or sys.path)], + newname, path or [*manager.search_path, *sys.path], target) if spec: - spec.loader = PluginLoader(manager, newname, - spec.origin) + spec.loader = PluginLoader( # type: ignore + manager, newname, spec.origin) return spec index -= 1 return None diff --git a/packages/nonebot-adapter-mirai/nonebot/adapters/mirai/message.py b/packages/nonebot-adapter-mirai/nonebot/adapters/mirai/message.py index 48bfb179..6d061ccb 100644 --- a/packages/nonebot-adapter-mirai/nonebot/adapters/mirai/message.py +++ b/packages/nonebot-adapter-mirai/nonebot/adapters/mirai/message.py @@ -289,19 +289,6 @@ class MessageChain(BaseMessage[MessageSegment]): f'Type {type(message).__name__} is not supported in mirai adapter.' ) - @overrides(BaseMessage) - def reduce(self): - """ - :说明: - - 忽略为空的消息段, 合并相邻的纯文本消息段 - """ - for index, segment in enumerate(self): - segment: MessageSegment - if segment.is_text() and not str(segment).strip(): - self.pop(index) - super().reduce() - @overrides(BaseMessage) def _construct( self, message: Union[List[Dict[str, Any]], Iterable[MessageSegment]]