diff --git a/docs/architecture/optimization-checklist.md b/docs/architecture/optimization-checklist.md index ba2761a17..e26c2b7f5 100644 --- a/docs/architecture/optimization-checklist.md +++ b/docs/architecture/optimization-checklist.md @@ -102,7 +102,7 @@ ARCH-201 至 ARCH-204 均达到实现、验证、提交、推送和远端门禁 | Python 源码量 | 305,884 行 | 排除 `app/plugins/**`;61 个文件超过 1,000 行,11 个超过 2,000 行 | | 长方法 | 290 个超过 80 行 | AST 统计排除 `app/plugins/**`;65 个超过 150 行,21 个超过 250 行 | | 全量 mypy 历史债务 | 9,983 / 591 文件 | canonical `SearchChain` Facade 已补齐显式类型转发;strict frontier 当前覆盖 41 个文件,低水位只允许继续下降 | -| Ruff 历史诊断 | 630 | 低水位门禁通过,但规则集只覆盖 `E4/E7/E9/F/I` | +| Ruff 历史诊断 | 576 | 低水位门禁通过,但规则集只覆盖 `E4/E7/E9/F/I` | | 覆盖率低水位 | Application 81.88%,Domain 81.03% | Chain、Runtime、Agent、Adapter、Startup 未进入包级覆盖率门禁 | ### 3.3 热点文件 diff --git a/tests/fixtures/architecture/ruff-baseline.json b/tests/fixtures/architecture/ruff-baseline.json index 382cb7b08..76781ac45 100644 --- a/tests/fixtures/architecture/ruff-baseline.json +++ b/tests/fixtures/architecture/ruff-baseline.json @@ -18,9 +18,6 @@ "app/adapters/web/plugin/routes.py": { "I001": 1 }, - "app/agent/callback/__init__.py": { - "I001": 1 - }, "app/agent/llm/capability.py": { "I001": 1 }, @@ -36,162 +33,36 @@ "app/agent/middleware/memory.py": { "I001": 1 }, - "app/agent/middleware/policy.py": { - "I001": 1 - }, "app/agent/middleware/selection.py": { "I001": 1 }, - "app/agent/middleware/skills.py": { - "I001": 1 - }, "app/agent/middleware/subagents.py": { "I001": 1 }, "app/agent/middleware/utils.py": { "I001": 1 }, - "app/agent/policy/__init__.py": { - "I001": 1 - }, - "app/agent/policy/orchestrator.py": { - "I001": 1 - }, - "app/agent/policy/registry.py": { - "I001": 1 - }, - "app/agent/policy/sanitizer.py": { - "I001": 1 - }, - "app/agent/policy/secrets.py": { - "I001": 1 - }, - "app/agent/prompt/__init__.py": { - "I001": 1 - }, - "app/agent/runtime.py": { - "I001": 1 - }, - "app/agent/skills/metadata.py": { - "I001": 1 - }, "app/agent/tools/impl/_command_safety.py": { "I001": 1 }, - "app/agent/tools/impl/_music_utils.py": { - "I001": 1 - }, - "app/agent/tools/impl/_plugin_tool_utils.py": { - "I001": 3 - }, - "app/agent/tools/impl/_torrent_search_utils.py": { - "I001": 1 - }, - "app/agent/tools/impl/add_custom_filter_rule.py": { - "I001": 1 - }, "app/agent/tools/impl/ask_user_choice.py": { "I001": 1 }, "app/agent/tools/impl/browse_webpage.py": { "I001": 1 }, - "app/agent/tools/impl/delete_custom_filter_rule.py": { - "I001": 1 - }, "app/agent/tools/impl/execute_command.py": { "I001": 1 }, - "app/agent/tools/impl/get_recommendations.py": { - "I001": 1 - }, - "app/agent/tools/impl/get_search_results.py": { - "I001": 1 - }, - "app/agent/tools/impl/install_plugin.py": { - "I001": 1 - }, - "app/agent/tools/impl/list_directory.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_builtin_filter_rules.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_custom_filter_rules.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_installed_plugins.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_library_exists.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_library_latest.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_market_plugins.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_media_detail.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_plugin_config.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_popular_subscribes.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_subscribe_shares.py": { - "I001": 1 - }, - "app/agent/tools/impl/query_system_settings.py": { - "I001": 1 - }, "app/agent/tools/impl/recognize_captcha.py": { "I001": 1 }, - "app/agent/tools/impl/recognize_media.py": { - "I001": 1 - }, - "app/agent/tools/impl/reload_plugin.py": { - "I001": 1 - }, - "app/agent/tools/impl/run_workflow.py": { - "I001": 1 - }, - "app/agent/tools/impl/scrape_metadata.py": { - "I001": 1 - }, - "app/agent/tools/impl/search_media.py": { - "I001": 1 - }, - "app/agent/tools/impl/search_person_credits.py": { - "I001": 1 - }, - "app/agent/tools/impl/search_torrents.py": { - "I001": 1 - }, "app/agent/tools/impl/send_local_file.py": { "I001": 1 }, "app/agent/tools/impl/send_voice_message.py": { "I001": 1 }, - "app/agent/tools/impl/uninstall_plugin.py": { - "I001": 1 - }, - "app/agent/tools/impl/update_custom_identifiers.py": { - "I001": 1 - }, - "app/agent/tools/impl/update_download_tasks.py": { - "I001": 1 - }, - "app/agent/tools/impl/update_plugin_config.py": { - "I001": 1 - }, - "app/agent/tools/impl/update_system_settings.py": { - "I001": 1 - }, "app/application/downloader.py": { "I001": 1 }, @@ -690,9 +561,6 @@ "app/runtime/state.py": { "I001": 1 }, - "app/schemas/agent.py": { - "I001": 1 - }, "app/schemas/common.py": { "I001": 1 }, @@ -800,21 +668,12 @@ "tests/test_acoustid_module.py": { "I001": 1 }, - "tests/test_agent_activity_log.py": { - "I001": 1 - }, - "tests/test_agent_lazy_runtime_boundary.py": { - "F401": 1 - }, "tests/test_agent_llm_capability.py": { "I001": 1 }, "tests/test_agent_recognize_captcha_tool.py": { "I001": 1 }, - "tests/test_agent_runtime.py": { - "I001": 1 - }, "tests/test_agent_session_status.py": { "I001": 1 }, @@ -827,21 +686,12 @@ "tests/test_agent_tokens_events.py": { "I001": 1 }, - "tests/test_agent_tool_factory_cache.py": { - "I001": 1 - }, "tests/test_agent_tool_result_policy.py": { "I001": 1 }, - "tests/test_agent_tool_streaming.py": { - "I001": 1 - }, "tests/test_agent_tool_timeouts.py": { "I001": 1 }, - "tests/test_agent_transfer_file_tool.py": { - "F401": 1 - }, "tests/test_api_authorization.py": { "I001": 1 }, @@ -857,9 +707,6 @@ "tests/test_bangumi_media_type.py": { "F401": 1 }, - "tests/test_builtin_skill_boundaries.py": { - "I001": 1 - }, "tests/test_capability_registry.py": { "I001": 1 }, @@ -998,9 +845,6 @@ "tests/test_main_direct_execution.py": { "I001": 1 }, - "tests/test_mcp_plugin_tools.py": { - "I001": 1 - }, "tests/test_media_identity_cleanup_migration.py": { "I001": 1 }, diff --git a/tests/test_agent_data_ports.py b/tests/test_agent_data_ports.py index 6629d3b3b..66a37e17b 100644 --- a/tests/test_agent_data_ports.py +++ b/tests/test_agent_data_ports.py @@ -19,6 +19,7 @@ from app.application.agenttask import AgentTaskRepository, AgentTaskSnapshot from app.application.filtering import FilterRuleService from app.db.adapters.agent import TransactionalAgentTaskRepository from app.db.session import SessionFactory + # pylint: disable=no-name-in-module # Scheduler 由惰性稳定入口导出,Pylint 无法静态解析。 from app.scheduler import Scheduler from app.schemas.rule import CustomRule diff --git a/tests/test_agent_tool_policy.py b/tests/test_agent_tool_policy.py index 6738ee952..fcea9b3c3 100644 --- a/tests/test_agent_tool_policy.py +++ b/tests/test_agent_tool_policy.py @@ -12,6 +12,7 @@ from app.agent.middleware.activity import ActivityLogMiddleware from app.agent.middleware.memory import MemoryMiddleware from app.agent.middleware.policy import AgentPolicyMiddleware from app.agent.middleware.summarization import FinalRequestCompactionMiddleware + # pylint: disable=no-name-in-module # 策略包根通过 __getattr__ 惰性导出,Pylint 无法静态解析。 from app.agent.policy import ( DEFAULT_TOOL_POLICY_ORCHESTRATOR, diff --git a/tests/test_rule_group_media.py b/tests/test_rule_group_media.py index 24271ddb7..8c5e0cbdd 100644 --- a/tests/test_rule_group_media.py +++ b/tests/test_rule_group_media.py @@ -3,6 +3,7 @@ from unittest.mock import MagicMock from app.application.filtering import normalize_media_type from app.application.rules import RuleHelper + # pylint: disable=no-name-in-module # SubscribeChain 由惰性稳定入口导出,Pylint 无法静态解析。 from app.chain.subscribe import SubscribeChain from app.domain.context import MediaInfo, MusicInfo, TorrentInfo diff --git a/tests/test_web_agent_stream.py b/tests/test_web_agent_stream.py index d7d9c30ce..8b8bc0e81 100644 --- a/tests/test_web_agent_stream.py +++ b/tests/test_web_agent_stream.py @@ -9,6 +9,7 @@ import pytest from app import schemas from app.agent.contracts import ReplyMode + # pylint: disable=no-name-in-module # 旧公开入口由 runtime compat 惰性注入,Pylint 无法静态解析。 from app.agent.orchestrator import agent_manager from app.agent.web import _get_web_agent_type