diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py index 7d61cfd1aca..a8a66ede316 100755 --- a/build_files/utils/make_test.py +++ b/build_files/utils/make_test.py @@ -54,7 +54,7 @@ if not (lib_tests_dirpath / ".git").exists(): sys.exit(1) # Ensure the test data files sub-module is configured and present. - make_utils.git_enable_submodule(git_command, "tests/data") + make_utils.git_enable_submodule(git_command, Path("tests") / "data") make_utils.git_update_submodule(args.git_command, lib_tests_dirpath) # Run cmake again to detect tests files. diff --git a/build_files/utils/make_update.py b/build_files/utils/make_update.py index 299dd6a0ced..0c256b4bd72 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -22,7 +22,10 @@ from pathlib import Path from make_utils import call, check_output from urllib.parse import urljoin, urlsplit -from typing import Optional +from typing import ( + Optional, + Tuple, +) def print_stage(text: str) -> None: @@ -91,7 +94,7 @@ def get_effective_architecture(args: argparse.Namespace) -> str: NOTE: When cross-compiling the architecture is coming from the command line argument. """ - architecture = args.architecture + architecture: Optional[str] = args.architecture if architecture: assert isinstance(architecture, str) elif "ARM64" in platform.version(): @@ -106,10 +109,11 @@ def get_effective_architecture(args: argparse.Namespace) -> str: assert (architecture in {"x64", "arm64"}) + assert isinstance(architecture, str) return architecture -def get_submodule_directories(args: argparse.Namespace): +def get_submodule_directories(args: argparse.Namespace) -> Tuple[Path, ...]: """ Get list of all configured submodule directories. """ @@ -121,8 +125,8 @@ def get_submodule_directories(args: argparse.Namespace): return () submodule_directories_output = check_output( - [args.git_command, "config", "--file", dot_modules, "--get-regexp", "path"]) - return [Path(line.split(' ', 1)[1]) for line in submodule_directories_output.strip().splitlines()] + [args.git_command, "config", "--file", str(dot_modules), "--get-regexp", "path"]) + return tuple([Path(line.split(' ', 1)[1]) for line in submodule_directories_output.strip().splitlines()]) def ensure_git_lfs(args: argparse.Namespace) -> None: @@ -304,7 +308,7 @@ def external_script_copy_old_submodule_over( def floating_checkout_initialize_if_needed(args: argparse.Namespace, repo_name: str, directory: Path, - old_submodules_dir: Path = None) -> None: + old_submodules_dir: Optional[Path] = None) -> None: """Initialize checkout of an external repository""" blender_git_root = get_blender_git_root() @@ -397,8 +401,8 @@ def floating_checkout_update(args: argparse.Namespace, repo_name: str, directory: Path, branch: Optional[str], - old_submodules_dir: Path = None, - only_update=False) -> str: + old_submodules_dir: Optional[Path] = None, + only_update: bool = False) -> str: """Update a single external checkout with the given name in the scripts folder""" blender_git_root = get_blender_git_root() @@ -499,7 +503,7 @@ def floating_libraries_update(args: argparse.Namespace, branch: Optional[str]) - return msg -def add_submodule_push_url(args: argparse.Namespace): +def add_submodule_push_url(args: argparse.Namespace) -> None: """ Add pushURL configuration for all locally activated submodules, pointing to SSH protocol. """ diff --git a/build_files/utils/make_utils.py b/build_files/utils/make_utils.py index 7b3b17619fc..9d1685072e1 100755 --- a/build_files/utils/make_utils.py +++ b/build_files/utils/make_utils.py @@ -15,12 +15,18 @@ import sys from pathlib import Path from typing import ( + Dict, Sequence, Optional, ) -def call(cmd: Sequence[str], exit_on_error: bool = True, silent: bool = False, env=None) -> int: +def call( + cmd: Sequence[str], + exit_on_error: bool = True, + silent: bool = False, + env: Optional[Dict[str, str]] = None, +) -> int: if not silent: cmd_str = "" if env: @@ -135,7 +141,7 @@ def _git_submodule_config_key(submodule_dir: Path, key: str) -> str: return f"submodule.{submodule_dir_str}.{key}" -def is_git_submodule_enabled(git_command: str, submodule_dir: Path): +def is_git_submodule_enabled(git_command: str, submodule_dir: Path) -> bool: """Check whether submodule denoted by its directory within the repository is enabled""" git_root = Path(check_output([git_command, "rev-parse", "--show-toplevel"])) @@ -158,7 +164,7 @@ def is_git_submodule_enabled(git_command: str, submodule_dir: Path): return update.lower() != "none" -def git_enable_submodule(git_command: str, submodule_dir: Path): +def git_enable_submodule(git_command: str, submodule_dir: Path) -> None: """Enable submodule denoted by its directory within the repository""" command = (git_command, @@ -200,11 +206,11 @@ def git_update_submodule(git_command: str, submodule_dir: Path) -> bool: env = {"GIT_LFS_SKIP_SMUDGE": "1"} - if call((git_command, "submodule", "update", "--init", "--progress", submodule_dir), + if call((git_command, "submodule", "update", "--init", "--progress", str(submodule_dir)), exit_on_error=False, env=env) != 0: return False - return call((git_command, "-C", submodule_dir, "lfs", "pull"), + return call((git_command, "-C", str(submodule_dir), "lfs", "pull"), exit_on_error=False) == 0 diff --git a/tools/utils_maintenance/code_clean.py b/tools/utils_maintenance/code_clean.py index df6331dc92b..8f5b30b6f09 100755 --- a/tools/utils_maintenance/code_clean.py +++ b/tools/utils_maintenance/code_clean.py @@ -1466,7 +1466,7 @@ class edit_generators: is_default = False @staticmethod - def _header_exclude(f_basename: str) -> str: + def _header_exclude(f_basename: str) -> bool: # This header only exists to add additional warnings, removing it doesn't impact generated output. # Skip this file. if f_basename == "BLI_strict_flags.h":