diff --git a/src/nonebot_plugin_alconna/builtins/plugins/echo.py b/src/nonebot_plugin_alconna/builtins/plugins/echo.py index e3064da..6534efc 100644 --- a/src/nonebot_plugin_alconna/builtins/plugins/echo.py +++ b/src/nonebot_plugin_alconna/builtins/plugins/echo.py @@ -1,5 +1,5 @@ -from nonebot.plugin import PluginMetadata, inherit_supported_adapters from arclet.alconna import CommandMeta, namespace +from nonebot.plugin import PluginMetadata, inherit_supported_adapters from nonebot_plugin_alconna import Command from nonebot_plugin_alconna.builtins.extensions.reply import ReplyMergeExtension diff --git a/src/nonebot_plugin_alconna/builtins/plugins/help.py b/src/nonebot_plugin_alconna/builtins/plugins/help.py index 8e7dbdd..f3f6acc 100644 --- a/src/nonebot_plugin_alconna/builtins/plugins/help.py +++ b/src/nonebot_plugin_alconna/builtins/plugins/help.py @@ -3,10 +3,11 @@ from pathlib import Path from tarina import lang -from nonebot.plugin import PluginMetadata, inherit_supported_adapters +from nonebot.adapters import Bot from importlib_metadata import PackageNotFoundError, distribution +from nonebot.plugin import PluginMetadata, inherit_supported_adapters from arclet.alconna import Args, Field, Option, Alconna, Arparma, CommandMeta, namespace, store_true, command_manager -from nonebot.adapters import Bot + from nonebot_plugin_alconna import UniMessage, AlconnaMatcher, referent, on_alconna __plugin_meta__ = PluginMetadata( diff --git a/src/nonebot_plugin_alconna/model.py b/src/nonebot_plugin_alconna/model.py index 5d5e8c5..e4c7fdc 100644 --- a/src/nonebot_plugin_alconna/model.py +++ b/src/nonebot_plugin_alconna/model.py @@ -1,6 +1,7 @@ +from weakref import ReferenceType from typing_extensions import NotRequired from typing import Union, Generic, Literal, TypeVar, Optional, TypedDict -from weakref import ReferenceType + from pydantic import Field, BaseModel from arclet.alconna import Empty, Alconna, Arparma from arclet.alconna.duplication import Duplication diff --git a/src/nonebot_plugin_alconna/rule.py b/src/nonebot_plugin_alconna/rule.py index e359c08..6d7797c 100644 --- a/src/nonebot_plugin_alconna/rule.py +++ b/src/nonebot_plugin_alconna/rule.py @@ -1,7 +1,8 @@ import asyncio +import weakref import importlib from typing import Union, Literal, Optional, cast -import weakref + from nonebot.typing import T_State from tarina import lang, init_spec from nonebot.matcher import Matcher @@ -179,7 +180,9 @@ def __eq__(self, other: object) -> bool: def __hash__(self) -> int: return hash(self.command.__hash__()) - async def handle(self, cmd: Alconna, bot: Bot, event: Event, state: T_State, msg: UniMessage) -> Union[Arparma, Literal[False]]: + async def handle( + self, cmd: Alconna, bot: Bot, event: Event, state: T_State, msg: UniMessage + ) -> Union[Arparma, Literal[False]]: ctx = await self.executor.context_provider(event, bot, state) if self.comp_config is None: return cmd.parse(msg, ctx) diff --git a/src/nonebot_plugin_alconna/uniseg/message.py b/src/nonebot_plugin_alconna/uniseg/message.py index d9e5f41..576362d 100644 --- a/src/nonebot_plugin_alconna/uniseg/message.py +++ b/src/nonebot_plugin_alconna/uniseg/message.py @@ -6,11 +6,11 @@ from dataclasses import dataclass from collections.abc import Iterable from typing_extensions import Self, SupportsIndex -from typing import TYPE_CHECKING, Any, Union, Literal, TypeVar, NoReturn, Optional, overload, Callable +from typing import TYPE_CHECKING, Any, Union, Literal, TypeVar, Callable, NoReturn, Optional, overload from tarina import lang -from tarina.lang.model import LangItem from nepattern import parser +from tarina.lang.model import LangItem from nonebot.exception import FinishedException from nonebot.internal.adapter import Bot, Event, Message from nonebot.internal.matcher import current_bot, current_event diff --git a/tests/test_uniseg.py b/tests/test_uniseg.py index 8534bdf..fe8cb5a 100644 --- a/tests/test_uniseg.py +++ b/tests/test_uniseg.py @@ -34,7 +34,11 @@ def test_unimsg(): ) msg1 = UniMessage.at("123").at_channel("456").at_role("789") - assert repr(msg1) == "[At(flag='user', target='123', display=None), At(flag='channel', target='456', display=None), At(flag='role', target='789', display=None)]" + assert repr(msg1) == ( + "[At(flag='user', target='123', display=None), " + "At(flag='channel', target='456', display=None), " + "At(flag='role', target='789', display=None)]" + ) assert msg1.filter(At, lambda x: x.flag == "user") == UniMessage.at("123")