style(test): 修 loader unit-sampling 测试的 ruff 告警
TC003 将 Path 导入移入 TYPE_CHECKING 块(仅注解使用), C408 将 base = dict(...) 改为字典字面量。行为不变。
This commit is contained in:
@@ -13,7 +13,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
from pathlib import Path
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import pytest
|
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 app.question_gen.loader import load_benchmark, stratified_sample
|
||||||
from core.types import GeneratedQuestion
|
from core.types import GeneratedQuestion
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def _single(qid: str, task_type: str = "Single") -> GeneratedQuestion:
|
def _single(qid: str, task_type: str = "Single") -> GeneratedQuestion:
|
||||||
"""构造一道 single 题(无 pair 归属)。"""
|
"""构造一道 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]:
|
def _pair(pid: str, task_type: str = "AR") -> list[GeneratedQuestion]:
|
||||||
"""构造一个合法孪生对(original + mirror),共享 pair_id / unit_id / flip_axis。"""
|
"""构造一个合法孪生对(original + mirror),共享 pair_id / unit_id / flip_axis。"""
|
||||||
base = dict(
|
base = {
|
||||||
video_id="v",
|
"video_id": "v",
|
||||||
task_type=task_type,
|
"task_type": task_type,
|
||||||
question="?",
|
"question": "?",
|
||||||
options=("A", "B", "C", "D"),
|
"options": ("A", "B", "C", "D"),
|
||||||
answer="A",
|
"answer": "A",
|
||||||
source_nodes=(),
|
"source_nodes": (),
|
||||||
difficulty="hard",
|
"difficulty": "hard",
|
||||||
pair_id=pid,
|
"pair_id": pid,
|
||||||
unit_id=pid,
|
"unit_id": pid,
|
||||||
flip_axis="before_after",
|
"flip_axis": "before_after",
|
||||||
)
|
}
|
||||||
return [
|
return [
|
||||||
GeneratedQuestion(question_id=f"{pid}_o", question_role="pair_original", **base),
|
GeneratedQuestion(question_id=f"{pid}_o", question_role="pair_original", **base),
|
||||||
GeneratedQuestion(question_id=f"{pid}_m", question_role="pair_mirror", **base),
|
GeneratedQuestion(question_id=f"{pid}_m", question_role="pair_mirror", **base),
|
||||||
|
|||||||
Reference in New Issue
Block a user