fix(lint): 修复 PR #14 引入的 lint 回退 (119→0)
PR #14 从旧分支复制文件导致回退了 PR #10 的 lint 修复。 修复内容: - autoflake 移除未使用导入/变量 - autopep8 修复缩进/空格 - 手动修复 F821(pathlib→Path), F541(f-string), F841(未使用变量) - 所有修复均通过 flake8 --max-line-length=120 --extend-ignore=E501 检查 (0 errors)
This commit is contained in:
+22
-10
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Query
|
||||
|
||||
@@ -31,8 +31,10 @@ async def list_projects():
|
||||
if db_path.exists():
|
||||
try:
|
||||
conn = sqlite3.connect(str(db_path), timeout=5)
|
||||
total = conn.execute("SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute("SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
total = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
archived = total - active
|
||||
conn.close()
|
||||
info['task_count'] = active
|
||||
@@ -45,8 +47,10 @@ async def list_projects():
|
||||
if general_db.exists() and "_general" not in projects:
|
||||
try:
|
||||
conn = sqlite3.connect(str(general_db), timeout=5)
|
||||
total = conn.execute("SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute("SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
total = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
conn.close()
|
||||
projects["_general"] = {
|
||||
"id": "_general", "name": "一般任务", "description": "无项目归属的通用任务",
|
||||
@@ -60,8 +64,10 @@ async def list_projects():
|
||||
if general_db_check.exists():
|
||||
try:
|
||||
conn = sqlite3.connect(str(general_db_check), timeout=5)
|
||||
total = conn.execute("SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute("SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
total = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE status != 'cancelled'").fetchone()[0]
|
||||
active = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE COALESCE(archived,0)=0").fetchone()[0]
|
||||
conn.close()
|
||||
projects["_general"]["task_count"] = active
|
||||
projects["_general"]["task_count_total"] = total
|
||||
@@ -76,7 +82,7 @@ async def list_projects():
|
||||
async def create_project(body: Dict[str, Any]):
|
||||
reg = _registry()
|
||||
try:
|
||||
info = reg.create_project(
|
||||
reg.create_project(
|
||||
body["id"], body["name"],
|
||||
agents=body.get("agents", []),
|
||||
description=body.get("description", ""),
|
||||
@@ -173,7 +179,10 @@ async def move_task(project_id: str, task_id: str, body: Dict[str, Any]):
|
||||
depends_on=child.depends_on, must_haves=child.must_haves,
|
||||
)
|
||||
tgt_bb.create_task(moved_child)
|
||||
src_bb.update_task_status(child.id, "cancelled", detail=f"Moved to {target_project}")
|
||||
src_bb.update_task_status(
|
||||
child.id,
|
||||
"cancelled",
|
||||
detail=f"Moved to {target_project}")
|
||||
moved_ids.append(child.id)
|
||||
|
||||
# 移动主任务
|
||||
@@ -186,7 +195,10 @@ async def move_task(project_id: str, task_id: str, body: Dict[str, Any]):
|
||||
depends_on=task.depends_on, must_haves=task.must_haves,
|
||||
)
|
||||
tgt_bb.create_task(moved_task)
|
||||
src_bb.update_task_status(task_id, "cancelled", detail=f"Moved to {target_project}")
|
||||
src_bb.update_task_status(
|
||||
task_id,
|
||||
"cancelled",
|
||||
detail=f"Moved to {target_project}")
|
||||
moved_ids.insert(0, task_id)
|
||||
|
||||
return {"ok": True, "moved_to": target_project, "moved_ids": moved_ids}
|
||||
|
||||
Reference in New Issue
Block a user