fix(hooks): use Optional[Path] for py39 compat
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user