diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e27293f..dc2bb23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,3 +64,4 @@ repos: - id: mypy exclude: ^(tests/) additional_dependencies: [types-all] + args: [--ignore-missing-imports, --disallow-untyped-defs] diff --git a/pyhelper_utils/general.py b/pyhelper_utils/general.py index 1ede883..efe6864 100644 --- a/pyhelper_utils/general.py +++ b/pyhelper_utils/general.py @@ -3,7 +3,7 @@ from time import sleep from functools import wraps from logging import Logger -from typing import Any +from typing import Any, Callable def tts(ts: Any) -> int: @@ -60,9 +60,9 @@ def ignore_exceptions( any: the underline function return value. """ - def wrapper(func): + def wrapper(func: Callable) -> Callable: @wraps(func) - def inner(*args, **kwargs): + def inner(*args: Any, **kwargs: Any) -> Any: try: return func(*args, **kwargs) except Exception as ex: diff --git a/pyhelper_utils/runners.py b/pyhelper_utils/runners.py index 2133847..d112b64 100644 --- a/pyhelper_utils/runners.py +++ b/pyhelper_utils/runners.py @@ -8,7 +8,7 @@ LOGGER = get_logger(name="runners") -def function_runner_with_pdb(func: Callable, dry_run: bool = False, *args, **kwargs) -> Any: +def function_runner_with_pdb(func: Callable, dry_run: bool = False, *args: Any, **kwargs: Any) -> Any: """ Run function with support to drop into pdb. diff --git a/pyhelper_utils/shell.py b/pyhelper_utils/shell.py index 5f8e52d..479869b 100644 --- a/pyhelper_utils/shell.py +++ b/pyhelper_utils/shell.py @@ -1,5 +1,5 @@ import subprocess -from typing import Optional +from typing import Any, List, Optional from simple_logger.logger import get_logger @@ -9,15 +9,15 @@ def run_command( - command: list, + command: List[str], verify_stderr: bool = True, shell: bool = False, timeout: Optional[int] = None, capture_output: bool = True, check: bool = True, hide_log_command: bool = False, - **kwargs, -) -> tuple: + **kwargs: Any, +) -> tuple[bool, str, str]: """ Run command locally.