style(test): 修 loader unit-sampling 测试的 ruff 告警

TC003 将 Path 导入移入 TYPE_CHECKING 块(仅注解使用),
C408 将 base = dict(...) 改为字典字面量。行为不变。
This commit is contained in:
2026-07-15 06:30:14 -04:00
parent d6a3107e4e
commit c412698cff
+16 -13
View File
@@ -13,7 +13,7 @@ from __future__ import annotations
import json
import random
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
@@ -21,6 +21,9 @@ from app.harness.question_units import build_units
from app.question_gen.loader import load_benchmark, stratified_sample
from core.types import GeneratedQuestion
if TYPE_CHECKING:
from pathlib import Path
def _single(qid: str, task_type: str = "Single") -> GeneratedQuestion:
"""构造一道 single 题(无 pair 归属)。"""
@@ -38,18 +41,18 @@ def _single(qid: str, task_type: str = "Single") -> GeneratedQuestion:
def _pair(pid: str, task_type: str = "AR") -> list[GeneratedQuestion]:
"""构造一个合法孪生对(original + mirror),共享 pair_id / unit_id / flip_axis。"""
base = dict(
video_id="v",
task_type=task_type,
question="?",
options=("A", "B", "C", "D"),
answer="A",
source_nodes=(),
difficulty="hard",
pair_id=pid,
unit_id=pid,
flip_axis="before_after",
)
base = {
"video_id": "v",
"task_type": task_type,
"question": "?",
"options": ("A", "B", "C", "D"),
"answer": "A",
"source_nodes": (),
"difficulty": "hard",
"pair_id": pid,
"unit_id": pid,
"flip_axis": "before_after",
}
return [
GeneratedQuestion(question_id=f"{pid}_o", question_role="pair_original", **base),
GeneratedQuestion(question_id=f"{pid}_m", question_role="pair_mirror", **base),