From d2208787b4b2ddc17e6111009ecf1075562430da Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Thu, 12 Nov 2026 12:01:59 +0900 Subject: [PATCH] chore: clear typehinting errors in build scripts --- scripts/parse_toml.py | 3 ++- scripts/prebuild.py | 6 +++--- scripts/release.py | 4 ++-- scripts/scrot.py | 14 ++++++++++---- scripts/untracked.py | 17 +++++++---------- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/parse_toml.py b/scripts/parse_toml.py index e4b5210..612f832 100644 --- a/scripts/parse_toml.py +++ b/scripts/parse_toml.py @@ -1,8 +1,9 @@ import tomllib from shared import get_git_root +from typing import Any -def get_entrypoint() -> None: +def get_entrypoint() -> Any: root = get_git_root() p = root.joinpath("pyproject.toml") with open(p, "rb") as f: diff --git a/scripts/prebuild.py b/scripts/prebuild.py index 143bc56..cdf97f2 100644 --- a/scripts/prebuild.py +++ b/scripts/prebuild.py @@ -52,7 +52,7 @@ def untar(file: str, glob: str, renamed: str) -> None: os.rename(_dir, build_dir.joinpath(renamed)) -def install_deps() -> None: +def install_deps() -> int: pip = build_dir.joinpath(f"{CPYTHON_BUILD}/bin/pip") proc = subprocess.run([pip, "install", root]) return proc.returncode @@ -65,12 +65,12 @@ def repackage() -> None: tar.add(build_dir.joinpath(CPYTHON_BUILD), arcname="python") -def rebuild_cpython() -> None: +def rebuild_cpython() -> str: if cpython_dir.is_dir() is False: get_cpython() code = install_deps() if code != 0: - return + return "" repackage() return get_packaged_version() diff --git a/scripts/release.py b/scripts/release.py index 2afaf47..934ef7c 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -92,8 +92,8 @@ with tarfile.open(tarpath, "w:gz") as tar: tar.add(subfolder, arcname=appname, filter=update_uname) print(f"Wrote tarfile to '{tarpath}'") -proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True) -assert proc.stdout.rstrip() == version +built_proc = subprocess.run([release_exe, "-v"], capture_output=True, text=True) +assert str(built_proc.stdout).rstrip() == version # TODO: clean up staging directory release_exe.unlink() diff --git a/scripts/scrot.py b/scripts/scrot.py index 3800197..be400d4 100644 --- a/scripts/scrot.py +++ b/scripts/scrot.py @@ -8,7 +8,13 @@ def get_image_path() -> Path: return get_git_root().joinpath("dzgui/data/images/example.png") -p = get_image_path() -app = build_gui("", False) -app.set_automation_param("screenshot_path", p) -app.run(None) +def take_screenshot() -> None: + p = get_image_path() + app = build_gui("", False) + if app is None: + return + app.set_automation_param("screenshot_path", p) + app.run(None) + + +take_screenshot() diff --git a/scripts/untracked.py b/scripts/untracked.py index f53714d..d77fa26 100644 --- a/scripts/untracked.py +++ b/scripts/untracked.py @@ -3,14 +3,11 @@ import subprocess import sys cmd = ["git", "ls-files", "--others", "--exclude-standard"] -result = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True +result = subprocess.run( + cmd, capture_output=True, text=True ) -with open(".gitignore", "r") as f: - ignored = [line.rstrip() for line in f] - -untracked = [os.path.basename(line.rstrip()) for line in result.stdout] -for file in untracked: - if not any(file in item for item in ignored): - print(f"File '{file}' is untracked. Add to .gitignore file if this is intended.") - sys.exit(1) +untracked = [os.path.basename(line.rstrip()) for line in result.stdout.splitlines()] +if bool(untracked): + print(f"The following files are untracked. Add to .gitignore if this is intended.") + print("\n".join(untracked)) + sys.exit(1)