fix:修复代码兼容性写法

This commit is contained in:
jxxghp
2025-03-23 12:10:21 +08:00
parent 79411a7350
commit 2f38b3040d
27 changed files with 242 additions and 145 deletions
+11 -3
View File
@@ -3,18 +3,26 @@ import importlib
import pkgutil
import traceback
from pathlib import Path
from typing import List, Any
from typing import List, Any, Callable
from app.log import logger
FilterFuncType = Callable[[str, Any], bool]
def _default_filter(name: str, obj: Any) -> bool:
"""
默认过滤器
"""
return True
class ModuleHelper:
"""
模块动态加载
"""
@classmethod
def load(cls, package_path: str, filter_func=lambda name, obj: True) -> List[Any]:
def load(cls, package_path: str, filter_func: FilterFuncType = _default_filter) -> List[Any]:
"""
导入模块
:param package_path: 父包名
@@ -46,7 +54,7 @@ class ModuleHelper:
return submodules
@classmethod
def load_with_pre_filter(cls, package_path: str, filter_func=lambda name, obj: True) -> List[Any]:
def load_with_pre_filter(cls, package_path: str, filter_func: FilterFuncType = _default_filter) -> List[Any]:
"""
导入子模块
:param package_path: 父包名
+1 -1
View File
@@ -40,7 +40,7 @@ class ProgressHelper(metaclass=Singleton):
"text": "正在处理..."
}
def update(self, key: Union[ProgressKey, str], value: float = None, text: str = None):
def update(self, key: Union[ProgressKey, str], value: Union[float, int] = None, text: str = None):
if isinstance(key, Enum):
key = key.value
if not self._process_detail.get(key, {}).get('enable'):