fix: Update type hints to use newer Python syntax

- Replace Dict, List, Optional with dict, list,  < /dev/null |  None syntax
- Fix abstract method implementation in message.py
- Improve type annotations and function return types
- Remove unreachable code in get_current_task_tool.py
- Refactor HTML elements to use style attributes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
晴猫
2025-05-01 06:55:05 +09:00
parent 3d001da30e
commit 263e8d196a
29 changed files with 125 additions and 143 deletions

View File

@@ -3,7 +3,7 @@ from src.config.config import global_config
from src.common.logger_manager import get_logger
from src.plugins.moods.moods import MoodManager
from typing import Dict, Any
from typing import Any
logger = get_logger("change_mood_tool")
@@ -22,7 +22,7 @@ class ChangeMoodTool(BaseTool):
"required": ["text", "response_set"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> Dict[str, Any]:
async def execute(self, function_args: dict[str, Any], message_txt: str = "") -> dict[str, Any]:
"""执行心情改变
Args:
@@ -30,7 +30,7 @@ class ChangeMoodTool(BaseTool):
message_txt: 原始消息文本
Returns:
Dict: 工具执行结果
dict: 工具执行结果
"""
try:
response_set = function_args.get("response_set")

View File

@@ -19,7 +19,7 @@ class RelationshipTool(BaseTool):
"required": ["text", "changed_value", "reason"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> dict:
async def execute(self, function_args: dict[str, Any], message_txt: str = "") -> dict:
"""执行工具功能
Args:

View File

@@ -1,7 +1,7 @@
from src.do_tool.tool_can_use.base_tool import BaseTool
from src.plugins.schedule.schedule_generator import bot_schedule
from src.common.logger import get_module_logger
from typing import Dict, Any
from typing import Any
from datetime import datetime
logger = get_module_logger("get_current_task_tool")
@@ -21,7 +21,7 @@ class GetCurrentTaskTool(BaseTool):
"required": ["start_time", "end_time"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> Dict[str, Any]:
async def execute(self, function_args: dict[str, Any], message_txt: str = "") -> dict[str, Any]:
"""执行获取当前任务或指定时间段的日程信息
Args:
@@ -29,7 +29,7 @@ class GetCurrentTaskTool(BaseTool):
message_txt: 原始消息文本,此工具不使用
Returns:
Dict: 工具执行结果
dict: 工具执行结果
"""
start_time = function_args.get("start_time")
end_time = function_args.get("end_time")
@@ -55,5 +55,6 @@ class GetCurrentTaskTool(BaseTool):
task_info = "\n".join(task_list)
else:
task_info = f"{start_time}{end_time} 之间没有找到日程信息"
else:
task_info = "请提供有效的开始时间和结束时间"
return {"name": "get_current_task", "content": f"日程信息: {task_info}"}

View File

@@ -1,6 +1,6 @@
from src.do_tool.tool_can_use.base_tool import BaseTool
from src.common.logger import get_module_logger
from typing import Dict, Any
from typing import Any
logger = get_module_logger("get_mid_memory_tool")
@@ -18,7 +18,7 @@ class GetMidMemoryTool(BaseTool):
"required": ["id"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> Dict[str, Any]:
async def execute(self, function_args: dict[str, Any], message_txt: str = "") -> dict[str, Any]:
"""执行记忆获取
Args:
@@ -26,7 +26,7 @@ class GetMidMemoryTool(BaseTool):
message_txt: 原始消息文本
Returns:
Dict: 工具执行结果
dict: 工具执行结果
"""
try:
id = function_args.get("id")

View File

@@ -17,7 +17,7 @@ class SendEmojiTool(BaseTool):
"required": ["text"],
}
async def execute(self, function_args: Dict[str, Any], message_txt: str = "") -> Dict[str, Any]:
async def execute(self, function_args: dict[str, Any], message_txt: str = "") -> dict[str, Any]:
text = function_args.get("text", message_txt)
return {
"name": "send_emoji",