P2 §5.3: 23 处 importlib.import_module → 静态 from import
把剩余 5 个文件里所有动态导入 douyin_screenshot_manager 的 importlib 调用 替换为顶部静态 from import 模式: - douyin/detection/douyin_pixel.py 7 处 - douyin/detection/douyin_detection.py 8 处 - douyin/fudai/douyin_fudai_finder.py 4 处 - douyin/fudai/core/fudai_attend.py 2 处 - gui/gui_app.py 2 处 douyin_screenshot_manager 只引用 douyin.core.path_config,与上述 5 个文件 无循环依赖。bin/run_cli.py 的剩余 1 处 importlib 是有意为之 (绕过 package __init__ 遮蔽),保留。 收益: - 可读性 + IDE 跳转/类型提示 - 每次调用省去 ~100µs 的 import_module 开销(detection 模块在热路径上调用密集) - 死代码减少 ~92 行(5 个文件合计 -115 / +23) 回归:140 .py 编译通过;importlib 残留只剩 bin/run_cli 故意 1 处; 5 个模块导入 + fudai_analyse + should_skip_fudai_by_config 业务链路正常; test_filter_logging / check_web_gui_config_sync 通过。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
7001919642
commit
0d01dabb69
5 files changed
+23
-115
No files matched your search
+2
-10
@@ -1672,11 +1672,7 @@ def main():
|
||||
|
||||
def on_reset_async_counters():
|
||||
try:
|
||||
import importlib
|
||||
|
||||
douyin_screenshot_manager = importlib.import_module(
|
||||
"douyin.handlers.douyin_screenshot_manager"
|
||||
)
|
||||
from douyin.handlers import douyin_screenshot_manager
|
||||
douyin_screenshot_manager.reset_async_save_counters()
|
||||
debug_async_success_var.set(0)
|
||||
debug_async_failure_var.set(0)
|
||||
@@ -1690,11 +1686,7 @@ def main():
|
||||
# 周期性更新计数器(2秒)
|
||||
def _update_async_counters():
|
||||
try:
|
||||
import importlib
|
||||
|
||||
douyin_screenshot_manager = importlib.import_module(
|
||||
"douyin.handlers.douyin_screenshot_manager"
|
||||
)
|
||||
from douyin.handlers import douyin_screenshot_manager
|
||||
s, f = douyin_screenshot_manager.get_async_save_counters()
|
||||
debug_async_success_var.set(s)
|
||||
debug_async_failure_var.set(f)
|
||||
|
||||
Reference in new issue
Block a user