From 0344959d46751df9c2dc381e9428a29dbd45a611 Mon Sep 17 00:00:00 2001 From: "Brian D. Evans" <252620095+briandevans@users.noreply.github.com> Date: Fri, 24 Apr 2026 14:26:18 -0700 Subject: [PATCH] test+types: address Copilot nits on #15318 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three minor cleanups from Copilot's review on #15318: 1. ``_parse_launchd_list_output`` return type: ``set`` → ``set[int]`` (matches the ``seen: set[int] = set()`` style elsewhere in the module). 2. ``_get_service_pids`` return type + local: same parameterization; was bare ``set`` before this branch existed, but Copilot flagged the pre-existing annotation while reviewing the diff so worth tightening as a drive-by. 3. ``unittest.mock.patch`` was imported in ``test_gateway_pid_detection_macos.py`` but never called — the tests use ``monkeypatch`` exclusively. Removed the unused import. No behaviour change. 39/39 tests still pass locally. Co-Authored-By: Claude Opus 4.7 (1M context) --- hermes_cli/gateway.py | 8 ++++---- tests/hermes_cli/test_gateway_pid_detection_macos.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index 4a477ff653..1616c1b36f 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -69,7 +69,7 @@ class GatewayRuntimeSnapshot: _LAUNCHD_PLIST_PID_RE = re.compile(r'"PID"\s*=\s*(\d+)\s*;') -def _parse_launchd_list_output(stdout: str, label: str) -> set: +def _parse_launchd_list_output(stdout: str, label: str) -> set[int]: """Extract PIDs for ``label`` from ``launchctl list`` output. macOS ``launchctl list`` has two distinct output formats and which one @@ -90,7 +90,7 @@ def _parse_launchd_list_output(stdout: str, label: str) -> set: because the plist-dict dump is already scoped to the label the caller requested. """ - pids: set = set() + pids: set[int] = set() if not stdout: return pids @@ -122,7 +122,7 @@ def _parse_launchd_list_output(stdout: str, label: str) -> set: return pids -def _get_service_pids() -> set: +def _get_service_pids() -> set[int]: """Return PIDs currently managed by systemd or launchd gateway services. Used to avoid killing freshly-restarted service processes when sweeping @@ -130,7 +130,7 @@ def _get_service_pids() -> set: service manager having committed the new PID before the restart command returns (true for both systemd and launchd in practice). """ - pids: set = set() + pids: set[int] = set() # --- systemd (Linux): user and system scopes --- if supports_systemd_services(): diff --git a/tests/hermes_cli/test_gateway_pid_detection_macos.py b/tests/hermes_cli/test_gateway_pid_detection_macos.py index a1cba9a9f2..2ad4aad5ce 100644 --- a/tests/hermes_cli/test_gateway_pid_detection_macos.py +++ b/tests/hermes_cli/test_gateway_pid_detection_macos.py @@ -33,7 +33,6 @@ These tests pin the fixes at the production-code entry points: invocation ever regresses to ``eww``. """ from types import SimpleNamespace -from unittest.mock import patch import pytest