From 8b44905d1784c95bd80331aa91cc9fbe2b6ee04a Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 4 Nov 2024 11:17:57 +0100 Subject: bin scripts: Use the NoReturn type hint The NoReturn type hint should be used to ensure the return type of methods calling no-return methods are not falsely enforced to an Optional return type. Add the NoReturn type hint as needed and clear up existing Optional returns together with any corresponding casts affected by the above. While there, also fix formatting. --- bin/parallel-bootstrap-traverser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin/parallel-bootstrap-traverser.py') diff --git a/bin/parallel-bootstrap-traverser.py b/bin/parallel-bootstrap-traverser.py index ee5bb194..f27525d7 100755 --- a/bin/parallel-bootstrap-traverser.py +++ b/bin/parallel-bootstrap-traverser.py @@ -23,7 +23,7 @@ import sys import threading from enum import Enum from argparse import ArgumentParser -from typing import Any, Callable, Dict, List, Optional, Tuple, cast +from typing import Any, Callable, Dict, List, NoReturn, Optional, Tuple, cast # generic JSON type that avoids getter issues; proper use is being enforced by # return types of methods and typing vars holding return values of json getters @@ -195,11 +195,11 @@ class AtomicListMap: g_CALLBACKS_PER_ID = AtomicListMap() -def log(*args: str, **kwargs: Any): +def log(*args: str, **kwargs: Any) -> None: print(*args, file=sys.stderr, **kwargs) -def fail(s: str): +def fail(s: str) -> NoReturn: log(s) sys.exit(1) @@ -236,7 +236,7 @@ def link(src: str, dest: str) -> None: os.symlink(src, dest) -def build_local(desc: Json, *, root: str, config: Json) -> Optional[str]: +def build_local(desc: Json, *, root: str, config: Json) -> str: repo_name: str = desc["data"]["repository"] repo: List[str] = config["repositories"][repo_name]["workspace_root"] rel_path: str = desc["data"]["path"] -- cgit v1.2.3