From d4c476b7d3fa4e232e94cf687b19c86d6c8b9336 Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Fri, 8 May 2026 02:16:07 -0300 Subject: [PATCH] fix(hooks): use Optional[Path] for py39 compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PEP 604 union syntax (Path | None) requires Python 3.10+. The project still supports 3.9 (per pyproject target-version and CI matrix), and this annotation lives in a function signature so it is evaluated at module load time — failing with "unsupported operand type(s) for |" on test-linux 3.9. The other ``int | None`` annotation in this file is inside a function body, where Python skips runtime evaluation of local annotations, so it does not trip 3.9. --- mempalace/hooks_cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mempalace/hooks_cli.py b/mempalace/hooks_cli.py index f7753a0..b8d07e0 100644 --- a/mempalace/hooks_cli.py +++ b/mempalace/hooks_cli.py @@ -14,6 +14,7 @@ import subprocess import sys from datetime import datetime from pathlib import Path +from typing import Optional SAVE_INTERVAL = 15 STATE_DIR = Path.home() / ".mempalace" / "hook_state" @@ -343,7 +344,7 @@ def _mine_already_running(cmd: list[str]) -> bool: return _pid_alive(int(recorded)) -def _claim_mine_slot(cmd: list[str]) -> Path | None: +def _claim_mine_slot(cmd: list[str]) -> Optional[Path]: """Atomically reserve the per-target PID slot for ``cmd``. Returns the slot path on success, or ``None`` if the target is