Skip to content

Commit 5add040

Browse files
committed
fix: 修复 ruff import 排序告警和 Django 镜像源 403 问题
- backend/app/core/background_init.py: 惰性导入按名称排序 - backend/app/router/note_router.py: first-party 导入块按字母序排列 - backend/app/services/note_service.py: 惰性导入顺序修正 - DjangoUserService/pyproject.toml: 默认索引改为 pypi.org,tuna 降为备用镜像
1 parent 56a63f7 commit 5add040

4 files changed

Lines changed: 4 additions & 5 deletions

File tree

DjangoUserService/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ include = ["DjangoUserService", "apps"]
3434

3535
[[tool.uv.index]]
3636
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
37-
default = true
3837

3938
[build-system]
4039
requires = ["setuptools", "wheel"]
4140
build-backend = "setuptools.build_meta"
4241

4342
[tool.uv]
44-
index-url = "https://pypi.tuna.tsinghua.edu.cn/simple"
43+
index-url = "https://pypi.org/simple"

backend/app/core/background_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def _init_note_service(self):
9191

9292
async def _init_reranker(self):
9393
"""检查并初始化重排序模型(触发 torch 等重型框架加载)"""
94-
from app.rag.reorder_service import check_and_download_reranker_model, ReorderService
94+
from app.rag.reorder_service import ReorderService, check_and_download_reranker_model
9595

9696
await asyncio.to_thread(check_and_download_reranker_model)
9797
logger.info("✅ 重排序模型检查完成")

backend/app/router/note_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pydantic import BaseModel
99
from sqlalchemy.ext.asyncio import AsyncSession
1010

11+
from app.core.background_init import init_manager
1112
from app.core.rate_limit import rate_limit
1213
from app.core.success_response import success_response
1314
from app.db.db_config import get_db
@@ -16,7 +17,6 @@
1617
NoteListResponse,
1718
NoteUpdate,
1819
)
19-
from app.core.background_init import init_manager
2020
from app.utils.auth_utils import get_current_user_id
2121

2222
note_router = APIRouter(prefix="/note", tags=["note"])

backend/app/services/note_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ async def _auto_tag_and_review(self, note_id: str, user_id: str, content: str):
375375
prompt = prompt_template.replace("{content}", content)
376376

377377
# 惰性导入避免模块级循环依赖
378-
from app.db.db_config import AsyncSessionLocal
379378
from app.core.background_init import init_manager
379+
from app.db.db_config import AsyncSessionLocal
380380
chat_model = init_manager.chat_model
381381

382382
response = await chat_model.ainvoke([HumanMessage(content=prompt)])

0 commit comments

Comments
 (0)