From f5cbe88c22672ce028915eea93c002cc756caef4 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Wed, 27 Jul 2022 10:34:21 +0800 Subject: [PATCH] ci: fix no subtyping for type annotation in python3.7 https://peps.python.org/pep-0544/ --- tools/ci/check_deprecated_kconfigs.py | 4 ++-- tools/ci/check_public_headers.py | 2 +- tools/ci/check_rules_yml.py | 2 +- tools/idf.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/ci/check_deprecated_kconfigs.py b/tools/ci/check_deprecated_kconfigs.py index e3a3d8e1ab..e734119d21 100755 --- a/tools/ci/check_deprecated_kconfigs.py +++ b/tools/ci/check_deprecated_kconfigs.py @@ -24,7 +24,7 @@ IGNORE_DIRS: Tuple = ( ) -def _parse_path(path: os.PathLike[str], sep: str=None) -> Set: +def _parse_path(path: 'os.PathLike[str]', sep: str=None) -> Set: ret = set() with open(path, 'r', encoding='utf-8') as f: for line in f: @@ -34,7 +34,7 @@ def _parse_path(path: os.PathLike[str], sep: str=None) -> Set: return ret -def _valid_directory(path: os.PathLike[str]) -> os.PathLike[str]: +def _valid_directory(path: 'os.PathLike[str]') -> 'os.PathLike[str]': if not os.path.isdir(path): raise argparse.ArgumentTypeError('{} is not a valid directory!'.format(path)) return path diff --git a/tools/ci/check_public_headers.py b/tools/ci/check_public_headers.py index dc209bd870..7816d2e180 100644 --- a/tools/ci/check_public_headers.py +++ b/tools/ci/check_public_headers.py @@ -56,7 +56,7 @@ def exec_cmd_to_temp_file(what: List, suffix: str='') -> Tuple[int, str, str, st return rc, out, err, out_file.name, cmd -def exec_cmd(what: List, out_file: Union[tempfile._TemporaryFileWrapper[bytes], int]=subprocess.PIPE) -> Tuple[int, str, str, str]: +def exec_cmd(what: List, out_file: Union['tempfile._TemporaryFileWrapper[bytes]', int]=subprocess.PIPE) -> Tuple[int, str, str, str]: p = subprocess.Popen(what, stdin=subprocess.PIPE, stdout=out_file, stderr=subprocess.PIPE) output_b, err_b = p.communicate() rc = p.returncode diff --git a/tools/ci/check_rules_yml.py b/tools/ci/check_rules_yml.py index 2f89fb8fed..36ebf4e03c 100755 --- a/tools/ci/check_rules_yml.py +++ b/tools/ci/check_rules_yml.py @@ -76,7 +76,7 @@ class YMLConfig: YML_CONFIG = YMLConfig(ROOT_YML_FP) -def validate_needed_rules(rules_yml: os.PathLike[str]) -> int: +def validate_needed_rules(rules_yml: 'os.PathLike[str]') -> int: res = 0 needed_rules = deepcopy(YML_CONFIG.all_extends) with open(rules_yml) as fr: diff --git a/tools/idf.py b/tools/idf.py index 7941f3b981..2a705e556d 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -472,7 +472,7 @@ def init_cli(verbose_output: List=None) -> Any: with open(os.path.join(args.build_dir, 'flasher_args.json')) as file: flasher_args: Dict[str, Any] = json.load(file) - def flasher_path(f: Union[str, os.PathLike[str]]) -> str: + def flasher_path(f: Union[str, 'os.PathLike[str]']) -> str: if type(args.build_dir) is bytes: args.build_dir = args.build_dir.decode() return _safe_relpath(os.path.join(args.build_dir, f))