♻️ fix lint problems

This commit is contained in:
FuQuan233 2025-04-26 00:27:10 +08:00
parent ed2f9051ef
commit 3c1ac4b68b
3 changed files with 10 additions and 12 deletions

View file

@ -5,7 +5,7 @@ inputs:
python-version: python-version:
description: Python version description: Python version
required: false required: false
default: "3.9" default: "3.10"
runs: runs:
using: "composite" using: "composite"

View file

@ -6,7 +6,7 @@ import os
import random import random
import re import re
import time import time
from typing import TYPE_CHECKING, Optional from typing import TYPE_CHECKING
import aiofiles import aiofiles
import httpx import httpx
@ -57,8 +57,8 @@ tasks: set["asyncio.Task"] = set()
def pop_reasoning_content( def pop_reasoning_content(
content: Optional[str], content: str | None,
) -> tuple[Optional[str], Optional[str]]: ) -> tuple[str | None, str | None]:
if content is None: if content is None:
return None, None return None, None
@ -82,7 +82,7 @@ class GroupState:
self.processing = False self.processing = False
self.last_active = time.time() self.last_active = time.time()
self.past_events = deque(maxlen=plugin_config.past_events_size) 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.output_reasoning_content = False
self.random_trigger_prob = plugin_config.random_trigger_prob 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( reply, matched_reasoning_content = pop_reasoning_content(
response.choices[0].message.content response.choices[0].message.content
) )
reasoning_content: Optional[str] = ( reasoning_content: str | None = (
getattr(response.choices[0].message, "reasoning_content", None) getattr(response.choices[0].message, "reasoning_content", None)
or matched_reasoning_content or matched_reasoning_content
) )

View file

@ -1,5 +1,3 @@
from typing import Optional
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -17,10 +15,10 @@ class PresetConfig(BaseModel):
class MCPServerConfig(BaseModel): class MCPServerConfig(BaseModel):
"""MCP服务器配置""" """MCP服务器配置"""
command: Optional[str] = Field(None, description="stdio模式下MCP命令") command: str | None = Field(None, description="stdio模式下MCP命令")
args: Optional[list[str]] = Field([], description="stdio模式下MCP命令参数") args: list[str] | None = Field([], description="stdio模式下MCP命令参数")
env: Optional[dict[str, str]] = Field({}, description="stdio模式下MCP命令环境变量") env: dict[str, str] | None = Field({}, description="stdio模式下MCP命令环境变量")
url: Optional[str] = Field(None, description="sse模式下MCP服务器地址") url: str | None = Field(None, description="sse模式下MCP服务器地址")
# 额外字段 # 额外字段
friendly_name: str = Field("", description="MCP服务器友好名称") friendly_name: str = Field("", description="MCP服务器友好名称")