refactor: 统一使用现代类型注解替代传统类型注解

- 将 Dict、List 等传统类型注解替换为 dict、list 等现代类型注解
- 更新类型注解以更精确地反映变量类型
- 修复部分类型注解与实际使用不匹配的问题
- 优化部分代码逻辑以提高类型安全性
This commit is contained in:
Yuyao Huang (Sam)
2026-03-28 14:27:21 +08:00
parent 64297e5e27
commit 09b63341cd
13 changed files with 72 additions and 55 deletions
+2 -2
View File
@@ -46,9 +46,9 @@ class HostConfig:
self.metaso_api_key: Optional[str] = data.get("METASO_API_KEY")
serves_users = data.get("SERVES_USERS", [])
self.serves_users: List[str] = serves_users if isinstance(serves_users, list) else []
self.serves_users: list[str] = serves_users if isinstance(serves_users, list) else []
self.capabilities: List[str] = data.get(
self.capabilities: list[str] = data.get(
"CAPABILITIES",
["claude_code", "shell", "file_ops", "web", "scheduler"],
)
+4 -5
View File
@@ -10,16 +10,15 @@ import asyncio
import logging
import secrets
import time
from typing import Optional
from typing import Any, Optional
import websockets
from websockets.client import WebSocketClientProtocol
from agent.manager import manager
from agent.scheduler import scheduler
from agent.task_runner import task_runner
from host_client.config import HostConfig, get_host_config
from orchestrator.agent import run as run_mailboy
from orchestrator.agent import agent
from orchestrator.tools import set_current_user, set_current_chat
from shared import (
RegisterMessage,
@@ -40,7 +39,7 @@ class NodeClient:
def __init__(self, config: HostConfig):
self.config = config
self.ws: Optional[WebSocketClientProtocol] = None
self.ws: Any = None
self._running = False
self._last_heartbeat = time.time()
self._reconnect_delay = 1.0
@@ -94,7 +93,7 @@ class NodeClient:
set_current_chat(request.chat_id)
try:
reply = await run_mailboy(request.user_id, request.text)
reply = await agent.run(request.user_id, request.text)
response = ForwardResponse(
id=request.id,