From f2ef951e42004ca21574346033f80bb1d628741a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Mar 2026 16:25:39 +0000 Subject: [PATCH] perf: optimize update_formula_file by removing redundant TOML parsing Co-authored-by: Serendeep <36764254+Serendeep@users.noreply.github.com> --- scripts/check-updates.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/check-updates.py b/scripts/check-updates.py index 7415e46..d92155e 100755 --- a/scripts/check-updates.py +++ b/scripts/check-updates.py @@ -105,7 +105,7 @@ def download_and_hash(url: str) -> str | None: return None -def update_formula_file(path: Path, new_version: str, new_url: str, new_sha256: str) -> None: +def update_formula_file(path: Path, old_version: str, new_version: str, new_url: str, new_sha256: str) -> None: """Update a formula TOML file with new version, source URL, and SHA-256.""" content = path.read_text() @@ -134,10 +134,6 @@ def update_formula_file(path: Path, new_version: str, new_url: str, new_sha256: ) # Update mirrors that contain the old version - # Read old version to find/replace in mirror URLs - with open(path, "rb") as f: - old_data = tomllib.load(f) - old_version = old_data["package"]["version"] if old_version != new_version: content = content.replace(old_version, new_version) @@ -233,6 +229,7 @@ def main() -> None: print(f" Applying update to {formula_path}...", file=sys.stderr) update_formula_file( formula_path, + result["current_version"], result["new_version"], result["new_url"], result["new_sha256"],