mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-08 23:09:15 +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>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
"""Module Integration Quality Scale 渐进门禁测试。"""
|
|
|
|
from pathlib import Path
|
|
|
|
from app.runtime.extensions.module.quality import (
|
|
MODULE_QUALITY_PROFILES,
|
|
QUALITY_RULES,
|
|
ModuleQualityLevel,
|
|
get_module_quality_profile,
|
|
)
|
|
|
|
MODULE_ROOT = Path(__file__).parents[1] / "app" / "modules"
|
|
|
|
|
|
def test_every_module_has_quality_view_with_owner_and_reason() -> None:
|
|
"""所有宿主模块都必须显式完成 assessed 登记,未知扩展才允许 legacy。"""
|
|
modules = {
|
|
path.name
|
|
for path in MODULE_ROOT.iterdir()
|
|
if path.is_dir() and not path.name.startswith(("_", "."))
|
|
}
|
|
|
|
assert modules
|
|
assert modules == set(MODULE_QUALITY_PROFILES)
|
|
for module in modules:
|
|
profile = get_module_quality_profile(module)
|
|
assert profile.owner
|
|
assert profile.level is ModuleQualityLevel.ASSESSED
|
|
assert profile.exemption_reason
|
|
|
|
assert get_module_quality_profile("third-party-unknown").level is (
|
|
ModuleQualityLevel.LEGACY
|
|
)
|
|
|
|
|
|
def test_assessed_profiles_only_use_declared_rules() -> None:
|
|
"""显式 profile 不得通过拼写新规则绕过统一质量维度。"""
|
|
for profile in MODULE_QUALITY_PROFILES.values():
|
|
assert profile.verified_rules
|
|
assert profile.verified_rules <= QUALITY_RULES
|
|
|
|
|
|
def test_bangumi_changed_slice_meets_required_quality_rules() -> None:
|
|
"""本轮修改的 Bangumi 模块必须满足配置快照切片相关门禁。"""
|
|
profile = get_module_quality_profile("bangumi")
|
|
|
|
assert profile.level is ModuleQualityLevel.ASSESSED
|
|
assert {
|
|
"fake-client-or-fixture",
|
|
"zero-real-network-tests",
|
|
"reload-stop-idempotent",
|
|
"module-contract-v2",
|
|
"owner-declared",
|
|
} <= profile.verified_rules
|