chore: perform widespread code cleanup and formatting

Perform a comprehensive code cleanup across multiple modules to improve code quality, consistency, and maintainability.

Key changes include:
- Removing numerous unused imports.
- Standardizing import order.
- Eliminating trailing whitespace and inconsistent newlines.
- Updating legacy type hints to modern syntax (e.g., `List` -> `list`).
- Making minor improvements for code robustness and style.
This commit is contained in:
minecraft1024a
2025-11-15 17:12:46 +08:00
parent bd45899dce
commit 6f62073630
26 changed files with 109 additions and 117 deletions

View File

@@ -5,7 +5,7 @@
import asyncio
import time
from typing import Any, TYPE_CHECKING
from typing import TYPE_CHECKING, Any
from src.chat.chatter_manager import ChatterManager
from src.chat.energy_system import energy_manager
@@ -115,12 +115,12 @@ class StreamLoopManager:
if not context:
logger.warning(f"无法获取流上下文: {stream_id}")
return False
# 快速路径:如果流已存在且不是强制启动,无需处理
if not force and context.stream_loop_task and not context.stream_loop_task.done():
logger.debug(f"🔄 [流循环] stream={stream_id[:8]}, 循环已在运行,跳过启动")
return True
# 获取或创建该流的启动锁
if stream_id not in self._stream_start_locks:
self._stream_start_locks[stream_id] = asyncio.Lock()