From b42dd2671c2d52c7481cbabb382f33f5eb14d0bc Mon Sep 17 00:00:00 2001 From: agb1986 Date: Sat, 8 Aug 2026 14:16:30 +0100 Subject: [PATCH] Fix hook crashing on every call under the host's Python 3.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit log_artifact_entry.py uses PEP 604 union syntax (str | None, dict | None) in three function signatures, which requires evaluating annotations at def time on Python < 3.10. The Docker image is fine (python:3.12-slim), but the hook itself runs directly on the host via PostToolUse, and the CasaOS host's only python3 is 3.9.2 — so the hook has raised TypeError on every single invocation, in every project, since it was installed. Silent, because hook stderr isn't surfaced anywhere visible. `from __future__ import annotations` defers annotation evaluation to strings, which fixes all three signatures with no syntax rewrite and no host Python upgrade needed. Co-Authored-By: Claude Sonnet 5 --- hooks/log_artifact_entry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hooks/log_artifact_entry.py b/hooks/log_artifact_entry.py index 3d77b40..8960850 100644 --- a/hooks/log_artifact_entry.py +++ b/hooks/log_artifact_entry.py @@ -35,6 +35,8 @@ resolve are dropped, and duplicates are removed. {content_length} is available when the artifact's top level is a list, {filename} always. """ +from __future__ import annotations + import json import os import re