From 066f7d9eeab3f3c5772745f6f0375649b367a49e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 28 Feb 2024 11:34:24 +0100 Subject: [PATCH] Revert "Cleanup: Address mypy errors and warnings" The similar cleanup with a lot of other changes were committed to the main branch. Is easier to revert this change, copy the scripts from main, and merge things back. This reverts commit 4bc1ba3c2d579b2bd4746eac71c0de948985fa45. --- build_files/utils/make_test.py | 2 +- build_files/utils/make_update.py | 16 ++++++++-------- build_files/utils/make_utils.py | 11 +++++------ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/build_files/utils/make_test.py b/build_files/utils/make_test.py index a8a66ede316..7d61cfd1aca 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, Path("tests") / "data") + make_utils.git_enable_submodule(git_command, "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 4840cf1a1bd..152f30ef270 100755 --- a/build_files/utils/make_update.py +++ b/build_files/utils/make_update.py @@ -106,10 +106,10 @@ def get_effective_architecture(args: argparse.Namespace) -> str: assert (architecture in ("x64", "arm64")) - return str(architecture) + return architecture -def get_submodule_directories(args: argparse.Namespace) -> list[Path]: +def get_submodule_directories(args: argparse.Namespace): """ Get list of all configured submodule directories. """ @@ -118,10 +118,10 @@ def get_submodule_directories(args: argparse.Namespace) -> list[Path]: dot_modules = blender_git_root / ".gitmodules" if not dot_modules.exists(): - return [] + return () submodule_directories_output = check_output( - [args.git_command, "config", "--file", str(dot_modules), "--get-regexp", "path"]) + [args.git_command, "config", "--file", dot_modules, "--get-regexp", "path"]) return [Path(line.split(' ', 1)[1]) for line in submodule_directories_output.strip().splitlines()] @@ -304,7 +304,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: Optional[Path] = None) -> None: + old_submodules_dir: Path = None) -> None: """Initialize checkout of an external repository""" blender_git_root = get_blender_git_root() @@ -397,8 +397,8 @@ def floating_checkout_update(args: argparse.Namespace, repo_name: str, directory: Path, branch: Optional[str], - old_submodules_dir: Optional[Path] = None, - only_update: bool = False) -> str: + old_submodules_dir: Path = None, + only_update=False) -> str: """Update a single external checkout with the given name in the scripts folder""" blender_git_root = get_blender_git_root() @@ -499,7 +499,7 @@ def floating_libraries_update(args: argparse.Namespace, branch: Optional[str]) - return msg -def add_submodule_push_url(args: argparse.Namespace) -> None: +def add_submodule_push_url(args: argparse.Namespace): """ 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 0c284ca8574..7b3b17619fc 100755 --- a/build_files/utils/make_utils.py +++ b/build_files/utils/make_utils.py @@ -20,8 +20,7 @@ from typing import ( ) -def call(cmd: Sequence[str], exit_on_error: bool = True, - silent: bool = False, env: Optional[dict[str, str]] = None) -> int: +def call(cmd: Sequence[str], exit_on_error: bool = True, silent: bool = False, env=None) -> int: if not silent: cmd_str = "" if env: @@ -136,7 +135,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) -> bool: +def is_git_submodule_enabled(git_command: str, submodule_dir: Path): """Check whether submodule denoted by its directory within the repository is enabled""" git_root = Path(check_output([git_command, "rev-parse", "--show-toplevel"])) @@ -159,7 +158,7 @@ def is_git_submodule_enabled(git_command: str, submodule_dir: Path) -> bool: return update.lower() != "none" -def git_enable_submodule(git_command: str, submodule_dir: Path) -> None: +def git_enable_submodule(git_command: str, submodule_dir: Path): """Enable submodule denoted by its directory within the repository""" command = (git_command, @@ -201,11 +200,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", str(submodule_dir)), + if call((git_command, "submodule", "update", "--init", "--progress", submodule_dir), exit_on_error=False, env=env) != 0: return False - return call((git_command, "-C", str(submodule_dir), "lfs", "pull"), + return call((git_command, "-C", submodule_dir, "lfs", "pull"), exit_on_error=False) == 0