mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
fix(classification): satisfy mypy ratchet
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user