-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Root Cause
watchdog>=4 is listed in [project] dependencies in pyproject.toml — it is always installed as a hard production dependency. Despite this, two places treat it as optional:
1. Dead except ImportError in cli.py (_start_observer, line 128–137):
def _start_observer(session_path: Path, change_event: threading.Event) -> object | None:
"""Start a watchdog observer if available. Returns the observer or None."""
try:
from watchdog.observers import Observer # type: ignore[import-untyped]
...
except ImportError:
return None # ← unreachable: watchdog is a hard depThe except ImportError branch can never execute because watchdog is unconditionally installed. This is dead code that misleads future readers into thinking watchdog might be absent.
2. Misleading README (Installation section):
If
watchdogis installed, the display auto-refreshes when session files change (2-second debounce). Install it withuv add watchdogfor live-updating views.
This actively misleads users into running a redundant uv add watchdog for a feature that is always active.
Resolution Spec
Option A — keep watchdog optional (recommended if lightweight installs matter):
- Move
watchdog>=4from[project] dependenciesto[project.optional-dependencies]under a key likewatch - Keep the
try/except ImportErrorguard (it becomes live code again) - Update README to explain the optional install
Option B — watchdog is always-on (simpler):
- Remove the
try/except ImportErrorguard in_start_observer; import at module top level - Remove
_stop_observer'sgetattrdance (watchdog API is always present) - Fix README: "The display auto-refreshes when session files change (2-second debounce)." — no conditional phrasing
Either option removes the misleading copy. Pick whichever matches project intent.
Testing Requirement
- Add a unit test for
_start_observerthat asserts it returns a non-None observer when given an existing directory (proving the live code path works) - If going with Option A: add a test that mocks the
ImportErrorand asserts_start_observerreturnsNonegracefully - Verify README no longer contains
uv add watchdoglanguage
Generated by Code Health Analysis · ◷