summaryrefslogtreecommitdiff
path: root/bin/just-mr.py
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-11-04 11:17:57 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-11-28 12:19:43 +0100
commit8b44905d1784c95bd80331aa91cc9fbe2b6ee04a (patch)
tree27d9200b71d11742315a923cc972a867572dd3bf /bin/just-mr.py
parent9dc61e9faca5e8b05a1a2a2eed83a5468aeb6202 (diff)
downloadjustbuild-8b44905d1784c95bd80331aa91cc9fbe2b6ee04a.tar.gz
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.
Diffstat (limited to 'bin/just-mr.py')
-rwxr-xr-xbin/just-mr.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/bin/just-mr.py b/bin/just-mr.py
index 21413546..4b79c295 100755
--- a/bin/just-mr.py
+++ b/bin/just-mr.py
@@ -22,7 +22,7 @@ import sys
import tempfile
import time
import zlib
-from typing import Any, Dict, List, Optional, Set, Tuple, Union, cast
+from typing import Any, Dict, List, NoReturn, Optional, Set, Tuple, Union, cast
from argparse import ArgumentParser
from pathlib import Path
@@ -140,7 +140,7 @@ def log(*args: str, **kwargs: Any) -> None:
print(*args, file=sys.stderr, **kwargs)
-def fail(s: str, exit_code: int = 65) -> None:
+def fail(s: str, exit_code: int = 65) -> NoReturn:
log(f"Error: {s}")
sys.exit(exit_code)
@@ -701,7 +701,7 @@ def distdir_tree_id_file(content: str) -> str:
content)
-def distdir_checkout(desc: Json, repos: Json):
+def distdir_checkout(desc: Json, repos: Json) -> List[str]:
""" Logic for processing the distdir repo type.
"""
content: Dict[str, str] = {}
@@ -783,7 +783,7 @@ def distdir_checkout(desc: Json, repos: Json):
]
-def checkout(desc: Json, *, name: str, repos: Json) -> Optional[List[str]]:
+def checkout(desc: Json, *, name: str, repos: Json) -> List[str]:
repo_desc = resolve_repo(desc, repos=repos)
repo_type = repo_desc.get("type")
if repo_type == "git":
@@ -965,8 +965,7 @@ def fetch(*,
return os.path.commonpath([path, base]) == base
# warn if fetch_dir is in invocation workspace
- if g_WORKSPACE_ROOT and is_subpath(cast(str, fetch_dir),
- g_WORKSPACE_ROOT):
+ if g_WORKSPACE_ROOT and is_subpath(fetch_dir, g_WORKSPACE_ROOT):
repo = repos.get(main, {}).get("repository", {})
repo_path = repo.get("path", None)
if repo_path is not None and repo.get("type", None) == "file":
@@ -993,7 +992,7 @@ Warning: Writing distribution files to workspace location '{fetch_dir}',
print("%r --> %r (content: %s)" % (repo, distfile, content))
archive_fetch(repo_desc, content)
shutil.copyfile(cas_path(content),
- os.path.join(cast(str, fetch_dir), distfile))
+ os.path.join(fetch_dir, distfile))
sys.exit(0)