From 3c1ac4b68bbb9b05e7b5881504081e36ca797260 Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Sat, 26 Apr 2025 00:27:10 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20fix=20lint=20problems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/setup-python/action.yml | 2 +- nonebot_plugin_llmchat/__init__.py | 10 +++++----- nonebot_plugin_llmchat/config.py | 10 ++++------ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml index 382fd60..33816c5 100644 --- a/.github/actions/setup-python/action.yml +++ b/.github/actions/setup-python/action.yml @@ -5,7 +5,7 @@ inputs: python-version: description: Python version required: false - default: "3.9" + default: "3.10" runs: using: "composite" diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 8e5ef06..7c77659 100644 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -6,7 +6,7 @@ import os import random import re import time -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING import aiofiles import httpx @@ -57,8 +57,8 @@ tasks: set["asyncio.Task"] = set() def pop_reasoning_content( - content: Optional[str], -) -> tuple[Optional[str], Optional[str]]: + content: str | None, +) -> tuple[str | None, str | None]: if content is None: return None, None @@ -82,7 +82,7 @@ class GroupState: self.processing = False self.last_active = time.time() self.past_events = deque(maxlen=plugin_config.past_events_size) - self.group_prompt: Optional[str] = None + self.group_prompt: str | None = None self.output_reasoning_content = False self.random_trigger_prob = plugin_config.random_trigger_prob @@ -333,7 +333,7 @@ async def process_messages(group_id: int): reply, matched_reasoning_content = pop_reasoning_content( response.choices[0].message.content ) - reasoning_content: Optional[str] = ( + reasoning_content: str | None = ( getattr(response.choices[0].message, "reasoning_content", None) or matched_reasoning_content ) diff --git a/nonebot_plugin_llmchat/config.py b/nonebot_plugin_llmchat/config.py index 57737fa..5f316f8 100644 --- a/nonebot_plugin_llmchat/config.py +++ b/nonebot_plugin_llmchat/config.py @@ -1,5 +1,3 @@ -from typing import Optional - from pydantic import BaseModel, Field @@ -17,10 +15,10 @@ class PresetConfig(BaseModel): class MCPServerConfig(BaseModel): """MCP服务器配置""" - command: Optional[str] = Field(None, description="stdio模式下MCP命令") - args: Optional[list[str]] = Field([], description="stdio模式下MCP命令参数") - env: Optional[dict[str, str]] = Field({}, description="stdio模式下MCP命令环境变量") - url: Optional[str] = Field(None, description="sse模式下MCP服务器地址") + command: str | None = Field(None, description="stdio模式下MCP命令") + args: list[str] | None = Field([], description="stdio模式下MCP命令参数") + env: dict[str, str] | None = Field({}, description="stdio模式下MCP命令环境变量") + url: str | None = Field(None, description="sse模式下MCP服务器地址") # 额外字段 friendly_name: str = Field("", description="MCP服务器友好名称")