diff --git a/astrbot/_internal/runtime/orchestrator.py b/astrbot/_internal/runtime/orchestrator.py index 5d1a9a5a2..74da57185 100644 --- a/astrbot/_internal/runtime/orchestrator.py +++ b/astrbot/_internal/runtime/orchestrator.py @@ -13,10 +13,10 @@ import anyio from astrbot import logger from astrbot._internal.abc.base_astrbot_orchestrator import BaseAstrbotOrchestrator -from astrbot._internal.protocols._mcp.client import McpClient from astrbot._internal.protocols._abp.client import AstrbotAbpClient from astrbot._internal.protocols._acp.client import AstrbotAcpClient from astrbot._internal.protocols._lsp.client import AstrbotLspClient +from astrbot._internal.protocols._mcp.client import McpClient from astrbot._internal.stars import RuntimeStatusStar log = logger diff --git a/astrbot/cli/commands/cmd_conf.py b/astrbot/cli/commands/cmd_conf.py index 973f43dd5..bcca0a36f 100644 --- a/astrbot/cli/commands/cmd_conf.py +++ b/astrbot/cli/commands/cmd_conf.py @@ -9,8 +9,6 @@ This module provides: from __future__ import annotations -import binascii -import hashlib import json import zoneinfo from collections.abc import Callable diff --git a/astrbot/core/knowledge_base/kb_mgr.py b/astrbot/core/knowledge_base/kb_mgr.py index b1d9b9e5f..4bd24b932 100644 --- a/astrbot/core/knowledge_base/kb_mgr.py +++ b/astrbot/core/knowledge_base/kb_mgr.py @@ -1,7 +1,5 @@ from __future__ import annotations -import traceback - from pathlib import Path from typing import TYPE_CHECKING diff --git a/astrbot/core/platform/sources/discord/discord_platform_event.py b/astrbot/core/platform/sources/discord/discord_platform_event.py index 11343d582..96f2fd17c 100644 --- a/astrbot/core/platform/sources/discord/discord_platform_event.py +++ b/astrbot/core/platform/sources/discord/discord_platform_event.py @@ -277,10 +277,8 @@ class DiscordPlatformEvent(AstrMessageEvent): self.message_obj.raw_message, "mentions" ): return any( - - mention.id == int(self.message_obj.self_id) - for mention in self.message_obj.raw_message.mentions - + mention.id == int(self.message_obj.self_id) + for mention in self.message_obj.raw_message.mentions ) return False diff --git a/astrbot/core/platform/sources/line/line_adapter.py b/astrbot/core/platform/sources/line/line_adapter.py index 3359d97f3..cd6622127 100644 --- a/astrbot/core/platform/sources/line/line_adapter.py +++ b/astrbot/core/platform/sources/line/line_adapter.py @@ -352,10 +352,7 @@ class LinePlatformAdapter(Platform): if original_name: safe_stem = Path(original_name).stem.strip() safe_stem = "".join( - - ch if ch.isalnum() or ch in ("-", "_", ".") else "_" - for ch in safe_stem - + ch if ch.isalnum() or ch in ("-", "_", ".") else "_" for ch in safe_stem ) safe_stem = safe_stem.strip("._") if safe_stem: diff --git a/astrbot/core/platform/sources/misskey/misskey_adapter.py b/astrbot/core/platform/sources/misskey/misskey_adapter.py index 6f3dcfa2d..3a331e531 100644 --- a/astrbot/core/platform/sources/misskey/misskey_adapter.py +++ b/astrbot/core/platform/sources/misskey/misskey_adapter.py @@ -342,19 +342,14 @@ class MisskeyPlatformAdapter(Platform): user_info = self._user_cache.get(user_id_for_cache) text = add_at_mention_if_needed(text, user_info, has_at_user) has_file_components = any( - - isinstance(comp, Comp.Image) - or isinstance(comp, Comp.File) - or hasattr(comp, "convert_to_file_path") - or hasattr(comp, "get_file") - or any( - - hasattr(comp, a) - for a in ("file", "url", "path", "src", "source") - - ) - for comp in message_chain.chain - + isinstance(comp, Comp.Image) + or isinstance(comp, Comp.File) + or hasattr(comp, "convert_to_file_path") + or hasattr(comp, "get_file") + or any( + hasattr(comp, a) for a in ("file", "url", "path", "src", "source") + ) + for comp in message_chain.chain ) if not text or not text.strip(): if not has_file_components: @@ -445,10 +440,8 @@ class MisskeyPlatformAdapter(Platform): or hasattr(comp, "convert_to_file_path") or hasattr(comp, "get_file") or any( - - hasattr(comp, a) - for a in ("file", "url", "path", "src", "source") - + hasattr(comp, a) + for a in ("file", "url", "path", "src", "source") ) ): file_components.append(comp) diff --git a/astrbot/core/provider/provider.py b/astrbot/core/provider/provider.py index b4a57fd63..2238e8300 100644 --- a/astrbot/core/provider/provider.py +++ b/astrbot/core/provider/provider.py @@ -360,7 +360,9 @@ class EmbeddingProvider(AbstractProvider): results = await asyncio.gather(*tasks, return_exceptions=True) errors = [r for r in results if isinstance(r, Exception)] if errors: - error_msg = f"有 {len(errors)} 个批次处理失败: {'; '.join(str(e) for e in errors)}" + error_msg = ( + f"有 {len(errors)} 个批次处理失败: {'; '.join(str(e) for e in errors)}" + ) raise Exception(error_msg) return all_embeddings diff --git a/astrbot/core/provider/sources/dashscope_tts.py b/astrbot/core/provider/sources/dashscope_tts.py index 79acc0cd8..9d6201f8b 100644 --- a/astrbot/core/provider/sources/dashscope_tts.py +++ b/astrbot/core/provider/sources/dashscope_tts.py @@ -15,7 +15,9 @@ try: ) _MultiModalConversationType: type = MultiModalConversation -except ImportError: # pragma: no cover - older dashscope versions without Qwen TTS support +except ( + ImportError +): # pragma: no cover - older dashscope versions without Qwen TTS support MultiModalConversation = None # type: ignore _MultiModalConversationType = None # type: ignore diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 8bc764a0e..ba7d478b3 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -427,12 +427,10 @@ class ProviderGoogleGenAI(Provider): chain: list[Comp.BaseMessageComponent] = [] part: types.Part if all( - - part.inline_data - and part.inline_data.mime_type - and part.inline_data.mime_type.startswith("image/") - for part in result_parts - + part.inline_data + and part.inline_data.mime_type + and part.inline_data.mime_type.startswith("image/") + for part in result_parts ): chain.append(Comp.Plain("这是图片")) for part in result_parts: