From 62ff292e8ebfb7978af9163bfa74a1aaa1712541 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sun, 11 Aug 2024 11:39:45 +0800 Subject: [PATCH] style: ruff format code --- iamai/__init__.py | 2 +- iamai/bot.py | 4 +--- iamai/cli.py | 4 +--- iamai/libcore.pyi | 3 +-- .../iamai/adapter/bililive/__init__.py | 3 +-- .../iamai-adapter-console/iamai/adapter/console/__init__.py | 4 +--- packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py | 6 +++--- packages/iamai-adapter-kook/iamai/adapter/kook/event.py | 3 ++- packages/iamai-adapter-kook/iamai/adapter/kook/message.py | 4 +++- 9 files changed, 14 insertions(+), 19 deletions(-) diff --git a/iamai/__init__.py b/iamai/__init__.py index 0489aa2f..a5b30399 100644 --- a/iamai/__init__.py +++ b/iamai/__init__.py @@ -21,5 +21,5 @@ "Event", "MessageEvent", "Plugin", - "libcore" + "libcore", ] diff --git a/iamai/bot.py b/iamai/bot.py index 10b63ceb..d7626912 100644 --- a/iamai/bot.py +++ b/iamai/bot.py @@ -86,9 +86,7 @@ class Bot: plugin_state: Dict[str, Any] global_state: Dict[Any, Any] - _condition: ( - asyncio.Condition - ) # Condition used to handle get # pyright: ignore[reportUninitializedInstanceVariable] + _condition: asyncio.Condition # Condition used to handle get # pyright: ignore[reportUninitializedInstanceVariable] _current_event: Optional[Event[Any]] # Event currently pending _restart_flag: bool # Restart flag diff --git a/iamai/cli.py b/iamai/cli.py index fe9283a3..a3987cf8 100644 --- a/iamai/cli.py +++ b/iamai/cli.py @@ -161,7 +161,7 @@ def install_package(package_name, directory): with open(target_path, "wb") as file: for chunk in response.iter_content(chunk_size=8192): - file.write(chunk) + file.write(chunk) else: subprocess.run(["pip", "install", package_name]) @@ -241,5 +241,3 @@ def search_packages_with_dependency(dependency_name): click.echo(package) else: click.echo(f"No packages found with '{dependency_name}' in iamai dependencies.") - - \ No newline at end of file diff --git a/iamai/libcore.pyi b/iamai/libcore.pyi index 7da84a4f..2995b352 100644 --- a/iamai/libcore.pyi +++ b/iamai/libcore.pyi @@ -1,6 +1,5 @@ -class libcore(): +class libcore: """This is the core library of the package. It contains the main functions to be used by the user.""" def sum_as_string(self, a: int, b: int) -> int: """This function returns the sum of two numbers.""" ... - \ No newline at end of file diff --git a/packages/iamai-adapter-bililive/iamai/adapter/bililive/__init__.py b/packages/iamai-adapter-bililive/iamai/adapter/bililive/__init__.py index 438dd11d..4d22e7e1 100644 --- a/packages/iamai-adapter-bililive/iamai/adapter/bililive/__init__.py +++ b/packages/iamai-adapter-bililive/iamai/adapter/bililive/__init__.py @@ -186,8 +186,7 @@ async def handle_websocket_msg(self, msg: aiohttp.WSMessage): if header.operation == Operation.HEARTBEAT_REPLY: popularity = int.from_bytes( data[ - offset - + HEADER_STRUCT.size : offset + offset + HEADER_STRUCT.size : offset + HEADER_STRUCT.size + 4 ], diff --git a/packages/iamai-adapter-console/iamai/adapter/console/__init__.py b/packages/iamai-adapter-console/iamai/adapter/console/__init__.py index d7e5c3e5..1580d15e 100644 --- a/packages/iamai-adapter-console/iamai/adapter/console/__init__.py +++ b/packages/iamai-adapter-console/iamai/adapter/console/__init__.py @@ -1,6 +1,4 @@ -"""Console适配器。 - -""" +"""Console适配器。""" from asyncio import Condition diff --git a/packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py b/packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py index 9b2a2d49..fa857db1 100644 --- a/packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py +++ b/packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py @@ -107,9 +107,9 @@ async def websocket_connect(self) -> None: if response.status_code == 200: logger.success("Successed to get GateWay.") self._gateway_response = response.json() - self.bot.global_state["adapter"]["kook"]["bot_info"] = ( - await self._get_self_data(self.config.access_token) - ) + self.bot.global_state["adapter"]["kook"][ + "bot_info" + ] = await self._get_self_data(self.config.access_token) self.self_id = self.bot.global_state["adapter"]["kook"]["bot_info"].id_ self.self_name = self.bot.global_state["adapter"]["kook"][ "bot_info" diff --git a/packages/iamai-adapter-kook/iamai/adapter/kook/event.py b/packages/iamai-adapter-kook/iamai/adapter/kook/event.py index fd6fa009..e140414f 100644 --- a/packages/iamai-adapter-kook/iamai/adapter/kook/event.py +++ b/packages/iamai-adapter-kook/iamai/adapter/kook/event.py @@ -1,4 +1,5 @@ """Kook 适配器事件。""" + import asyncio import inspect from enum import IntEnum @@ -926,4 +927,4 @@ def get_event_class( return ( _kook_events.get(".".join((post_type, event_type, sub_type))) or _kook_events[".".join((post_type, event_type))] - ) # type: ignore \ No newline at end of file + ) # type: ignore diff --git a/packages/iamai-adapter-kook/iamai/adapter/kook/message.py b/packages/iamai-adapter-kook/iamai/adapter/kook/message.py index 8a14a7ef..42346f2d 100644 --- a/packages/iamai-adapter-kook/iamai/adapter/kook/message.py +++ b/packages/iamai-adapter-kook/iamai/adapter/kook/message.py @@ -245,7 +245,9 @@ def serialize(self, for_send: bool = True) -> Tuple[int, str]: if len(self.message) != 1: # 转化为卡片消息发送 - return MessageSerializer(KookMessage(_convert_to_card_message(self.message))).serialize() # type: ignore + return MessageSerializer( + KookMessage(_convert_to_card_message(self.message)) + ).serialize() # type: ignore msg_type = self.message[0].type msg_type_code = msg_type_map[msg_type]