fix(classification): satisfy mypy ratchet

This commit is contained in:
jxxghp
2026-09-04 12:25:31 +08:00
parent c0d05e7460
commit 0ecc2825e2
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -199,7 +199,8 @@ class RecentHistoryClassificationSampleProvider:
records: Sequence[tuple[_HistorySampleRecord, ClassificationFacts]],
) -> list[ClassificationFacts | None]:
"""以固定并发上限重新读取详情,并拒绝身份不一致的返回值。"""
if self._facts_resolver is None:
facts_resolver = self._facts_resolver
if facts_resolver is None:
return [projected for _, projected in records]
semaphore = asyncio.Semaphore(self._resolve_concurrency)
@@ -209,7 +210,7 @@ class RecentHistoryClassificationSampleProvider:
) -> ClassificationFacts | None:
async with semaphore:
try:
facts = await self._facts_resolver(record.payload)
facts = await facts_resolver(record.payload)
except Exception: # noqa: BLE001 单条详情失败不应阻断整批分析
return None
if facts is None or _classification_identity_key(facts) != _classification_identity_key(projected):
+1 -1
View File
@@ -531,7 +531,7 @@ class ClassificationMediaPreviewInput(_ClassificationModel):
kind: Literal["media"] = Field(default="media", description="预览输入类型")
media: dict[str, JsonData] = Field(description="从媒体搜索结果选择的媒体信息")
@model_validator(mode="after")
@model_validator(mode="after") # type: ignore[misc]
def validate_media_identity(self) -> "ClassificationMediaPreviewInput":
"""确保搜索结果包含分类所需的来源、编号和媒体类型。"""
source = str(self.media.get("media_source") or "").strip()