mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-01 04:47:03 +08:00
refactor(types): declare plugin catalog collection contracts
This commit is contained in:
@@ -23,12 +23,12 @@ from app.schemas.plugin import (
|
||||
PluginUpdateCandidate,
|
||||
)
|
||||
|
||||
MarketLoader = Callable[[str, Optional[str], bool], Optional[dict[str, dict]]]
|
||||
MarketLoader = Callable[[str, Optional[str], bool], Optional[dict[str, dict[str, Any]]]]
|
||||
AsyncMarketLoader = Callable[
|
||||
[str, Optional[str], bool],
|
||||
Awaitable[Optional[dict[str, dict]]],
|
||||
Awaitable[Optional[dict[str, dict[str, Any]]]],
|
||||
]
|
||||
PluginMapper = Callable[[str, dict, str, list[str], int, Optional[str]], Any]
|
||||
PluginMapper = Callable[[str, dict[str, Any], str, list[str], int, Optional[str]], Any]
|
||||
ProgressCallback = Callable[..., Any]
|
||||
DEFAULT_MARKET_FETCH_CONCURRENCY = 5
|
||||
|
||||
@@ -216,7 +216,7 @@ class PluginCatalogService:
|
||||
max_workers=self._max_concurrency
|
||||
) as executor:
|
||||
futures_meta: dict[
|
||||
concurrent.futures.Future,
|
||||
concurrent.futures.Future[Any],
|
||||
tuple[int, bool, int],
|
||||
] = {}
|
||||
for market_index, market in enumerate(markets):
|
||||
@@ -246,8 +246,8 @@ class PluginCatalogService:
|
||||
))
|
||||
|
||||
collected.sort(key=lambda item: (item[0], 0 if item[1] else 1, item[2]))
|
||||
higher_plugins = []
|
||||
base_plugins = []
|
||||
higher_plugins: list[Any] = []
|
||||
base_plugins: list[Any] = []
|
||||
for _market_index, is_higher, _flag_priority, plugins in collected:
|
||||
(higher_plugins if is_higher else base_plugins).extend(plugins)
|
||||
return self.merge(higher_plugins, base_plugins, markets)
|
||||
@@ -292,12 +292,12 @@ class PluginCatalogService:
|
||||
))
|
||||
|
||||
try:
|
||||
higher_plugins = []
|
||||
base_plugins = []
|
||||
higher_plugins: list[Any] = []
|
||||
base_plugins: list[Any] = []
|
||||
if tasks:
|
||||
total_tasks = len(tasks)
|
||||
finished_tasks = 0
|
||||
task_results = {}
|
||||
task_results: dict[int, tuple[str, list[Any]]] = {}
|
||||
if progress_callback:
|
||||
progress_callback(
|
||||
value=0,
|
||||
@@ -369,7 +369,7 @@ class PluginCatalogService:
|
||||
return markets.index(plugin.repo_url)
|
||||
return len(markets)
|
||||
|
||||
deduplicated = {}
|
||||
deduplicated: dict[tuple[Optional[str], Optional[str]], Any] = {}
|
||||
for plugin in sorted(all_plugins, key=repo_order):
|
||||
key = (
|
||||
normalize_physical_plugin_id(plugin.id),
|
||||
@@ -382,7 +382,7 @@ class PluginCatalogService:
|
||||
):
|
||||
deduplicated[key] = plugin
|
||||
|
||||
result_by_id = {}
|
||||
result_by_id: dict[str, Any] = {}
|
||||
for plugin in sorted(deduplicated.values(), key=repo_order):
|
||||
normalized_id = normalize_physical_plugin_id(plugin.id)
|
||||
exists = result_by_id.get(normalized_id)
|
||||
@@ -450,13 +450,13 @@ class PluginCatalogService:
|
||||
|
||||
def _map_plugins(
|
||||
self,
|
||||
online_plugins: dict[str, dict],
|
||||
online_plugins: dict[str, dict[str, Any]],
|
||||
market: str,
|
||||
package_version: Optional[str],
|
||||
) -> list[Any]:
|
||||
"""把一个市场索引映射为宿主插件 DTO。"""
|
||||
installed_plugins = self._installed_plugins_provider()
|
||||
result = []
|
||||
result: list[Any] = []
|
||||
add_time = len(online_plugins)
|
||||
for plugin_id, plugin_info in online_plugins.items():
|
||||
plugin = self._plugin_mapper(
|
||||
|
||||
@@ -75,7 +75,7 @@ uv run --locked --no-sync python scripts/architecture/complexity.py
|
||||
回调和返回值类型;全仓错误计数为零并不保证单独纳入 strict frontier 后也为零。
|
||||
|
||||
2026-10-16 开始逐文件清理类型债务,`app/domain/title.py` 通过局部可空类型声明保留
|
||||
既有搜索解析行为,并纳入严格清单;当前清单共 143 个文件(142 个生产文件和 1 个脚本)。
|
||||
既有搜索解析行为,并纳入严格清单;当前清单共 144 个文件(143 个生产文件和 1 个脚本)。
|
||||
每个治理提交聚焦一个生产文件及其必要测试、门禁配置、真实下降基线和指标文档。
|
||||
验收同时检查完整严格清单与全宿主 Linux 分析,避免 `follow_imports = skip` 隐藏依赖
|
||||
签名冲突;不通过忽略诊断或放宽类型合同接受回退。最新文件清单以 `mypy.ini` 为准,
|
||||
|
||||
@@ -108,7 +108,7 @@ ARCH-201 至 ARCH-204 均达到实现、验证、提交、推送和远端门禁
|
||||
| Event Contract | 53 | 均已有 payload model,但当前全部是 diagnostic enforcement |
|
||||
| Python 源码量 | 372,668 行 | 本次重新扫描物理行数,排除 `app/plugins/**`;74 个文件超过 1,000 行,12 个超过 2,000 行;源码尺寸仅作观察 |
|
||||
| 长方法 | 309 个超过 80 行 | 本次 AST 扫描排除 `app/plugins/**`;61 个超过 150 行,17 个超过 250 行;新增函数仍受 C901/嵌套深度门禁约束 |
|
||||
| 全量 mypy 历史债务 | 8,551 / 417 文件 | 通知排版补齐 Slack 消息块类型,历史债务减少 2 项;工作流资源过滤改用领域对象调用过滤链,恢复的节点输出在消费前归一化,并收紧可空资源列表的类型低水位;消息媒体交互类型债务已清零,canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降;微信 ClawBot 入站 item_list 媒体解析改为按子项键名分派后,类型错误减少 4 项;站点解析器分享率改用浮点初值,类型错误减少 20 项;本次下载与文件安全修复再减少 3 项;Transmission 进度回退值归一化再减少 2 项,逐文件逐错误码无增长 |
|
||||
| 全量 mypy 历史债务 | 8,540 / 416 文件 | 通知排版补齐 Slack 消息块类型,历史债务减少 2 项;工作流资源过滤改用领域对象调用过滤链,恢复的节点输出在消费前归一化,并收紧可空资源列表的类型低水位;消息媒体交互类型债务已清零,canonical Facade 与 endpoint 类型边界已补齐,低水位只允许继续下降;微信 ClawBot 入站 item_list 媒体解析改为按子项键名分派后,类型错误减少 4 项;站点解析器分享率改用浮点初值,类型错误减少 20 项;本次下载与文件安全修复再减少 3 项;Transmission 进度回退值归一化再减少 2 项,逐文件逐错误码无增长 |
|
||||
| Ruff 历史诊断 | 98 | 低水位门禁通过,但规则集只覆盖 `E4/E7/E9/F/I` |
|
||||
| 覆盖率固定基线 | Application 80.00%,Domain 80.00% | Chain、Runtime、Agent、Adapter、Startup 未进入包级覆盖率门禁 |
|
||||
|
||||
|
||||
1
mypy.ini
1
mypy.ini
@@ -96,6 +96,7 @@ files =
|
||||
app/application/subscription/identity.py,
|
||||
app/application/subscription/mutation.py,
|
||||
app/application/plugin/config.py,
|
||||
app/application/plugin/catalog.py,
|
||||
app/application/plugin/folders.py,
|
||||
app/application/plugin/routes.py,
|
||||
app/application/plugin/runtime.py,
|
||||
|
||||
@@ -632,10 +632,6 @@
|
||||
"app/application/module.py": {
|
||||
"misc": 1
|
||||
},
|
||||
"app/application/plugin/catalog.py": {
|
||||
"type-arg": 5,
|
||||
"var-annotated": 6
|
||||
},
|
||||
"app/application/plugin/management.py": {
|
||||
"arg-type": 2,
|
||||
"no-any-return": 2
|
||||
|
||||
Reference in New Issue
Block a user