ci: fix no subtyping for type annotation in python3.7

https://peps.python.org/pep-0544/
This commit is contained in:
Fu Hanxi 2022-07-27 10:34:21 +08:00
parent 0d6de25d1c
commit f5cbe88c22
4 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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))