Skip to content

Commit

Permalink
style: ruff format code
Browse files Browse the repository at this point in the history
  • Loading branch information
HsiangNianian committed Aug 11, 2024
1 parent 4670397 commit 62ff292
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion iamai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"Event",
"MessageEvent",
"Plugin",
"libcore"
"libcore",
]
4 changes: 1 addition & 3 deletions iamai/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions iamai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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.")


3 changes: 1 addition & 2 deletions iamai/libcore.pyi
Original file line number Diff line number Diff line change
@@ -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."""
...

Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Console适配器。
"""
"""Console适配器。"""

from asyncio import Condition

Expand Down
6 changes: 3 additions & 3 deletions packages/iamai-adapter-kook/iamai/adapter/kook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion packages/iamai-adapter-kook/iamai/adapter/kook/event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Kook 适配器事件。"""

import asyncio
import inspect
from enum import IntEnum
Expand Down Expand Up @@ -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
) # type: ignore
4 changes: 3 additions & 1 deletion packages/iamai-adapter-kook/iamai/adapter/kook/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 62ff292

Please sign in to comment.