Files
MoviePilot/app/schemas/common.py
freeman f3ad81b39e style: apply safe ruff auto-fixes and exempt startup late imports
Run `ruff check app tests scripts --fix` with the configured rule set
(E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders
(F541), lambda/variable/unused-import cleanups that ruff marks safe.
Nine files whose only ruff debt sits next to pre-existing pylint
import-resolution errors (lazy exports, sys.path script imports) or
whose "unused" imports are reached through attribute access by tests are
left untouched so the changed-file pylint gate and the benchmark tests
stay green; their diagnostics remain in the baseline.

app/startup/lifecycle/__init__.py and app/main.py import business
modules after cache composition, import-path and stdio setup on purpose
(the source comments document the contract), so declare E402
per-file-ignores for them instead of adding per-line noqa.

Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture
and the optimization checklist figure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-09 13:29:09 +08:00

90 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""API 端点共享的小型业务数据模型。"""
from typing import Any, Dict, Optional, Union
from pydantic import BaseModel, Field, RootModel
from typing_extensions import TypeAliasType
JsonData = TypeAliasType(
"JsonData",
Union[
dict[str, "JsonData"],
list["JsonData"],
str,
int,
float,
bool,
None,
],
)
"""可递归序列化的 JSON 数据;OpenAPI 会展示每一种合法 JSON 结构。"""
class JsonObject(RootModel[dict[str, JsonData]]):
"""字段由运行时扩展点决定的 JSON 对象。"""
class JsonObjectList(RootModel[list[JsonObject]]):
"""字段由运行时扩展点决定的 JSON 对象列表。"""
class IdData(BaseModel):
"""创建资源后返回的资源 ID。"""
id: Optional[int | str] = Field(default=None, description="资源 ID")
class ValueData(BaseModel):
"""单个动态配置值。"""
value: JsonData = Field(default=None, description="配置值")
class FileNameData(BaseModel):
"""文件操作结果中的文件名。"""
filename: Optional[str] = Field(default=None, description="文件名")
class NameData(BaseModel):
"""名称计算结果。"""
name: Optional[str] = Field(default=None, description="名称")
class ServiceClientInfo(BaseModel):
"""可选择的下载器或媒体服务器摘要。"""
name: Optional[str] = Field(default=None, description="实例名称")
type: Optional[str] = Field(default=None, description="服务类型")
class ProgressKeyData(BaseModel):
"""异步任务进度查询标识。"""
progress_key: str = Field(description="进度查询标识")
class BatchProgressKeyData(ProgressKeyData):
"""批量异步任务进度查询标识。"""
history_ids: list[int] = Field(default_factory=list, description="历史记录 ID 列表")
class TimeData(BaseModel):
"""网络请求耗时。"""
time: int | float = Field(description="耗时毫秒数")
class ManageRequest(BaseModel):
"""通用管理请求:目标标识 + 管理动作 + 透传参数
用于通知渠道、网盘存储等统一管理能力入口,
动作与参数的具体语义由目标模块自行解释
"""
target: str = Field(description="管理目标标识,如渠道名或存储类型")
action: str = Field(description="管理动作标识")
params: Dict[str, Any] = Field(default_factory=dict, description="表单与动作参数,透传给目标模块")