style: cleanup
This commit is contained in:
+12
-7
@@ -1,8 +1,13 @@
|
||||
default_install_hook_types: [pre-commit, prepare-commit-msg]
|
||||
ci:
|
||||
autofix_commit_msg: ":balloon: auto fixes by pre-commit hooks"
|
||||
autofix_prs: true
|
||||
autoupdate_branch: master
|
||||
autoupdate_schedule: weekly
|
||||
autoupdate_commit_msg: ":balloon: pre-commit autoupdate"
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.9.9
|
||||
hooks:
|
||||
# Run the linter.
|
||||
- id: ruff
|
||||
# Run the formatter.
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.9.9
|
||||
hooks:
|
||||
- id: ruff
|
||||
- id: ruff-format
|
||||
|
||||
@@ -84,7 +84,7 @@ class BaseMessageComponent(BaseModel):
|
||||
return output
|
||||
|
||||
def toDict(self):
|
||||
data = dict()
|
||||
data = {}
|
||||
for k, v in self.__dict__.items():
|
||||
if k == "type" or v is None:
|
||||
continue
|
||||
|
||||
@@ -278,7 +278,8 @@ class AiocqhttpAdapter(Platform):
|
||||
return self.metadata
|
||||
|
||||
async def shutdown_trigger_placeholder(self):
|
||||
while not self._event_queue.closed and not self.stop:
|
||||
# TODO: use asyncio.Event
|
||||
while not self._event_queue.closed and not self.stop: # noqa: ASYNC110
|
||||
await asyncio.sleep(1)
|
||||
logger.info("aiocqhttp 适配器已关闭。")
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import base64
|
||||
import datetime
|
||||
import re
|
||||
import os
|
||||
import anyio
|
||||
from astrbot.api.platform import AstrBotMessage, MessageMember, MessageType
|
||||
from astrbot.api.message_components import Plain, Image, At, Record
|
||||
from astrbot.api import logger, sp
|
||||
@@ -189,8 +190,8 @@ class SimpleGewechatClient:
|
||||
if "ImgBuf" in d and "buffer" in d["ImgBuf"]:
|
||||
voice_data = base64.b64decode(d["ImgBuf"]["buffer"])
|
||||
file_path = f"data/temp/gewe_voice_{abm.message_id}.silk"
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(voice_data)
|
||||
async with await anyio.open_file(file_path, "wb") as f:
|
||||
await f.write(voice_data)
|
||||
abm.message.append(Record(file=file_path, url=file_path))
|
||||
case _:
|
||||
logger.info(f"未实现的消息类型: {d['MsgType']}")
|
||||
@@ -251,7 +252,8 @@ class SimpleGewechatClient:
|
||||
)
|
||||
|
||||
async def shutdown_trigger_placeholder(self):
|
||||
while not self.event_queue.closed and not self.stop:
|
||||
# TODO: use asyncio.Event
|
||||
while not self.event_queue.closed and not self.stop: # noqa: ASYNC110
|
||||
await asyncio.sleep(1)
|
||||
logger.info("gewechat 适配器已关闭。")
|
||||
|
||||
|
||||
@@ -102,6 +102,6 @@ class QQOfficialWebhook:
|
||||
)
|
||||
|
||||
async def shutdown_trigger_placeholder(self):
|
||||
while not self.event_queue.closed:
|
||||
while not self.event_queue.closed: # noqa: ASYNC110
|
||||
await asyncio.sleep(1)
|
||||
logger.info("qq_official_webhook 适配器已关闭。")
|
||||
|
||||
@@ -94,7 +94,7 @@ class WecomServer:
|
||||
)
|
||||
|
||||
async def shutdown_trigger_placeholder(self):
|
||||
while not self.event_queue.closed:
|
||||
while not self.event_queue.closed: # noqa: ASYNC110
|
||||
await asyncio.sleep(1)
|
||||
logger.info("企业微信 适配器已关闭。")
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import uuid
|
||||
import os
|
||||
import edge_tts
|
||||
import subprocess
|
||||
import asyncio
|
||||
from ..provider import TTSProvider
|
||||
from ..entites import ProviderType
|
||||
from ..register import register_provider_adapter
|
||||
@@ -55,7 +56,7 @@ class ProviderEdgeTTS(TTSProvider):
|
||||
await communicate.save(mp3_path)
|
||||
|
||||
# 使用ffmpeg将MP3转换为标准WAV格式
|
||||
_ = subprocess.run(
|
||||
_ = await asyncio.create_subprocess_exec(
|
||||
[
|
||||
"ffmpeg",
|
||||
"-y", # 覆盖输出文件
|
||||
|
||||
@@ -71,7 +71,7 @@ class AstrBotDashboard:
|
||||
return r
|
||||
|
||||
async def shutdown_trigger_placeholder(self):
|
||||
while not self.core_lifecycle.event_queue.closed:
|
||||
while not self.core_lifecycle.event_queue.closed: # noqa: ASYNC110
|
||||
await asyncio.sleep(1)
|
||||
logger.info("管理面板已关闭。")
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ logo_tmpl = r"""
|
||||
___ _______.___________..______ .______ ______ .___________.
|
||||
/ \ / | || _ \ | _ \ / __ \ | |
|
||||
/ ^ \ | (----`---| |----`| |_) | | |_) | | | | | `---| |----`
|
||||
/ /_\ \ \ \ | | | / | _ < | | | | | |
|
||||
/ _____ \ .----) | | | | |\ \----.| |_) | | `--' | | |
|
||||
/__/ \__\ |_______/ |__| | _| `._____||______/ \______/ |__|
|
||||
|
||||
/ /_\ \ \ \ | | | / | _ < | | | | | |
|
||||
/ _____ \ .----) | | | | |\ \----.| |_) | | `--' | | |
|
||||
/__/ \__\ |_______/ |__| | _| `._____||______/ \______/ |__|
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ You need to generate python codes to solve user's problem: {prompt}
|
||||
{extra_input}
|
||||
|
||||
## Limit
|
||||
1. Available libraries:
|
||||
1. Available libraries:
|
||||
- standard libs
|
||||
- `Pillow`
|
||||
- `requests`
|
||||
@@ -40,8 +40,8 @@ You need to generate python codes to solve user's problem: {prompt}
|
||||
- `mplfonts`
|
||||
You can only use these libraries and the libraries that they depend on.
|
||||
2. Do not generate malicious code.
|
||||
3. Use given `shared.api` package to output the result.
|
||||
It has 3 functions: `send_text(text: str)`, `send_image(image_path: str)`, `send_file(file_path: str)`.
|
||||
3. Use given `shared.api` package to output the result.
|
||||
It has 3 functions: `send_text(text: str)`, `send_image(image_path: str)`, `send_file(file_path: str)`.
|
||||
For Image and file, you must save it to `output` folder.
|
||||
4. You must only output the code, do not output the result of the code and any other information.
|
||||
5. The output language is same as user's input language.
|
||||
@@ -58,7 +58,7 @@ def fabonacci(n):
|
||||
return n
|
||||
else:
|
||||
return fabonacci(n-1) + fabonacci(n-2)
|
||||
|
||||
|
||||
result = fabonacci(10)
|
||||
send_text("The fabonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, starting from 0 and 1.")
|
||||
send_text("Let's calculate the fabonacci sequence of 10: " + result) # send_text is a function to send pure text to user
|
||||
|
||||
+19
-4
@@ -1,6 +1,21 @@
|
||||
[tool.ruff]
|
||||
lint.ignore = ["F403", "F405"]
|
||||
exclude = [
|
||||
"astrbot/core/utils/t2i/local_strategy.py",
|
||||
"astrbot/api/all.py"
|
||||
]
|
||||
"astrbot/core/utils/t2i/local_strategy.py",
|
||||
"astrbot/api/all.py",
|
||||
]
|
||||
line-length = 88
|
||||
lint.ignore = [
|
||||
"F403",
|
||||
"F405",
|
||||
"E501",
|
||||
"ASYNC230" # TODO: handle ASYNC230 in AstrBot
|
||||
]
|
||||
lint.select = [
|
||||
"F", # Pyflakes
|
||||
"W", # pycodestyle warnings
|
||||
"E", # pycodestyle errors
|
||||
"ASYNC", # flake8-async
|
||||
"C4", # flake8-comprehensions
|
||||
"Q", # flake8-quotes
|
||||
]
|
||||
target-version = "py310"
|
||||
|
||||
Reference in New Issue
Block a user