refactor: remove unused imports and add TODO for anyio migration

This commit is contained in:
LIghtJUNction
2026-03-23 21:41:06 +08:00
parent 0b25f4eba1
commit 9d49acdce7
4 changed files with 7 additions and 35 deletions

View File

@@ -9,7 +9,6 @@ from __future__ import annotations
import asyncio
import json
import logging
from contextlib import asynccontextmanager
from typing import Any
@@ -21,7 +20,6 @@ from astrbot._internal.geteway.ws_manager import WebSocketManager
try:
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
except ImportError:
logger.warning("FastAPI not installed, gateway unavailable.")
FastAPI = None # type: ignore

View File

@@ -5,8 +5,6 @@ WebSocket connection manager for the AstrBot gateway.
from __future__ import annotations
import asyncio
import json
import logging
from typing import Any
from astrbot import logger

View File

@@ -71,6 +71,13 @@ class AstrbotOrchestrator(BaseAstrbotOrchestrator):
self._running = True
log.info("AstrbotOrchestrator run loop started.")
# TODO: Replace asyncio.sleep loop with proper task scheduling using anyio.
# The ASYNC110 warning is valid - this should use asyncio.Event.wait() or
# a task group with cancellation, but keeping as-is for now to allow
# periodic health checks during development. Final implementation should:
# - Use anyio.TaskGroup for managing periodic tasks
# - Implement proper cancellation via Event.wait()
# - Avoid busy-waiting with sleep intervals
try:
while self._running:
# TODO: Periodic tasks:

View File

@@ -1,31 +0,0 @@
# 开发者日记@lightjunction
为了避免和主分支发生大量冲突新架构设计全部移动至了_internel包
目前API不稳定并不希望外部导入这个内部包
新增astrbot dev子命令用于启动新架构
概念:
核心运行时core runtime
核心运行时是主进程
主要是启动一个后端这个后端将改为使用fastapi开发
插件称呼为star
astrboot这个名字就和星系相关插件当然就是一个一个星星了
Galaxy是星系
我们的核心运行时需要一个协议和插件对话
我思考我们的插件最好是可以做到和lsp服务器或者mcp服务器那样
我们需要一套新的协议
我列举本项目采用的协议如下:
lsp协议client
mcp协议client + server
acp协议client + server
abp协议astrbot protocol client + server (相当于内置插件)
协议层只管传输
runtime则负责响应和调度
异步库使用anyio
## 覆盖率测试
需要完善覆盖率测试
## 类型标注
需要通过ty类型检查
避免使用Any cast
## 代码风格
需要通过ruff检查
## 细节
使用uv run 运行一切别用python xxxx