mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-09 15:19:54 +08:00
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>
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""文件管理模块的惰性兼容入口。
|
||
|
||
宿主能力清单和历史调用方继续使用 ``app.modules.filemanager:FileManagerModule``;
|
||
实现移入 ``module`` 后,包初始化不再反向加载传输处理器和存储实现。
|
||
"""
|
||
|
||
from importlib import import_module
|
||
from typing import Any
|
||
|
||
_EXPORTS = {
|
||
"FileManagerModule": ("app.modules.filemanager.module", "FileManagerModule"),
|
||
}
|
||
|
||
|
||
def __getattr__(name: str) -> Any:
|
||
"""按需解析旧包级导出,并缓存解析结果。"""
|
||
contract = _EXPORTS.get(name)
|
||
if contract is None:
|
||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||
module_name, symbol_name = contract
|
||
value = getattr(import_module(module_name), symbol_name)
|
||
if name == "FileManagerModule":
|
||
# 保持插件反射、Pickle 和能力入口依赖的历史类路径。
|
||
value.__module__ = __name__
|
||
globals()[name] = value
|
||
return value
|
||
|
||
|
||
def __dir__() -> list[str]:
|
||
"""向交互式工具公开兼容符号而不提前导入实现。"""
|
||
return sorted({*globals(), *_EXPORTS})
|
||
|
||
|
||
__all__ = ["FileManagerModule"]
|