ruff check && format

This commit is contained in:
LIghtJUNction
2026-05-22 15:23:24 +08:00
parent 944afc4b33
commit 7c224ebbd2
7 changed files with 21 additions and 15 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ TContext = TypeVar("TContext", default=Any)
class ContextWrapper(Generic[TContext]):
"""A context for running an agent, which can be used to pass additional data or state."""
context: TContext = cast(TContext, None)
context: TContext = cast("TContext", None)
messages: list[Message] = Field(default_factory=list)
"""This field stores the llm message context for the agent run, agent runners will maintain this field automatically."""
tool_call_timeout: int = 120 # Default tool call timeout in seconds
+5 -5
View File
@@ -199,22 +199,22 @@ class BoxliteBooter(ComputerBooter):
sb_url=f"http://127.0.0.1:{random_port}",
)
raw_fs = ShipyardFileSystemComponent(
client=cast(Any, self.mocked),
client=cast("Any", self.mocked),
ship_id=self.box.id,
session_id=session_id,
)
self._python = ShipyardPythonComponent(
client=cast(Any, self.mocked),
client=cast("Any", self.mocked),
ship_id=self.box.id,
session_id=session_id,
)
raw_shell = ShipyardShellComponent(
client=cast(Any, self.mocked),
client=cast("Any", self.mocked),
ship_id=self.box.id,
session_id=session_id,
)
self._shell = ShipyardShellWrapper(cast(Any, raw_shell))
self._fs = ShipyardFileSystemWrapper(cast(Any, raw_fs), self._shell)
self._shell = ShipyardShellWrapper(cast("Any", raw_shell))
self._fs = ShipyardFileSystemWrapper(cast("Any", raw_fs), self._shell)
await self.mocked.wait_healthy(self.box.id, session_id)
@@ -223,7 +223,7 @@ class NeoFileSystemComponent(FileSystemComponent):
) -> dict[str, Any]:
if self._shell is None:
raise RuntimeError(
"NeoFileSystemComponent requires a shell for search_files."
"NeoFileSystemComponent requires a shell for search_files.",
)
return await search_files_via_shell(
self._shell,
@@ -668,7 +668,8 @@ class LarkMessageEvent(AstrMessageEvent):
return
if not original_audio_path or not await asyncio.to_thread(
os.path.exists, original_audio_path
os.path.exists,
original_audio_path,
):
logger.error(f"[Lark] 音频文件不存在: {original_audio_path}")
return
@@ -700,7 +701,8 @@ class LarkMessageEvent(AstrMessageEvent):
# 清理转换后的临时音频文件
if converted_audio_path and await asyncio.to_thread(
os.path.exists, converted_audio_path
os.path.exists,
converted_audio_path,
):
try:
await asyncio.to_thread(os.remove, converted_audio_path)
@@ -746,7 +748,8 @@ class LarkMessageEvent(AstrMessageEvent):
return
if not original_video_path or not await asyncio.to_thread(
os.path.exists, original_video_path
os.path.exists,
original_video_path,
):
logger.error(f"[Lark] 视频文件不存在: {original_video_path}")
return
@@ -778,7 +781,8 @@ class LarkMessageEvent(AstrMessageEvent):
# 清理转换后的临时视频文件
if converted_video_path and await asyncio.to_thread(
os.path.exists, converted_video_path
os.path.exists,
converted_video_path,
):
try:
await asyncio.to_thread(os.remove, converted_video_path)
+1 -1
View File
@@ -54,7 +54,7 @@ class GenieTTSProvider(TTSProvider):
)
except Exception as e:
raise RuntimeError(
f"Failed to load character {self.character_name}: {e}"
f"Failed to load character {self.character_name}: {e}",
) from e
def support_stream(self) -> bool:
+1 -1
View File
@@ -198,7 +198,7 @@ async def download_file(
start_time = time.time()
if show_progress:
logger.info(
f"Downloading: {url} | Size: {total_size / 1024:.2f} KB"
f"Downloading: {url} | Size: {total_size / 1024:.2f} KB",
)
await _emit_download_progress(
progress_callback,
+4 -2
View File
@@ -498,10 +498,12 @@ class StatRoute(Route):
# 验证最终路径在预期的 changelogs 目录内(防止路径遍历)
# 确保规范化后的路径以 changelogs_dir 开头,且是目录内的文件
changelog_path_normalized = await asyncio.to_thread(
os.path.normpath, changelog_path
os.path.normpath,
changelog_path,
)
changelogs_dir_normalized = await asyncio.to_thread(
os.path.normpath, changelogs_dir
os.path.normpath,
changelogs_dir,
)
# 检查路径是否在预期目录内(必须是目录的子文件,不能是目录本身)