From c25570eb863071f9748a13ddfa98e2a6f1a2bcd2 Mon Sep 17 00:00:00 2001 From: Justin Gu <97915@qq.com> Date: Thu, 11 Jun 2026 04:27:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mypy=20strict=20=E2=80=94=20type=20annot?= =?UTF-8?q?ate=20co=5Ffilename=20in=20=5Fget=5Fstrategy=5Ffile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/easy_tdx/screen/scanner.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/easy_tdx/screen/scanner.py b/src/easy_tdx/screen/scanner.py index 21c0e5c..5209403 100644 --- a/src/easy_tdx/screen/scanner.py +++ b/src/easy_tdx/screen/scanner.py @@ -536,16 +536,16 @@ def _get_strategy_file(strategy_cls: type) -> str: for attr_name in ("init", "next", "on_bar", "on_tick"): method = strategy_cls.__dict__.get(attr_name) if method is not None and hasattr(method, "__code__"): - filepath = method.__code__.co_filename + filepath: str = method.__code__.co_filename # type: ignore[assignment] if filepath and not filepath.startswith("<"): return filepath # 3. 任意自定义方法 for attr_val in strategy_cls.__dict__.values(): if callable(attr_val) and hasattr(attr_val, "__code__"): - filepath = attr_val.__code__.co_filename - if filepath and not filepath.startswith("<"): - return filepath + filepath2: str = attr_val.__code__.co_filename # type: ignore[assignment] + if filepath2 and not filepath2.startswith("<"): + return filepath2 raise ValueError( f"策略类 {strategy_cls.__name__} 无法定位源文件路径,"