refactor(paths): v3 design - explicit initialize_paths + frozen PathsConfig singleton

This commit is contained in:
ed
2026-06-19 09:40:01 -04:00
parent 3fb9f9ff8e
commit 327b388800
11 changed files with 338 additions and 251 deletions
+10 -9
View File
@@ -34,7 +34,7 @@ if _config_override_arg is None:
_config_override_arg = _ISOLATION_WORKSPACE / "config_overrides.toml"
from src import paths as _paths # noqa: E402
_paths.set_config_override(_config_override_arg)
_paths.initialize_paths(_config_override_arg)
thirdparty_dir = os.path.join(os.path.dirname(__file__), "..", "thirdparty")
if thirdparty_dir not in sys.path:
@@ -381,11 +381,11 @@ def isolate_workspace(monkeypatch) -> Generator[None, None, None]:
(tests/artifacts/_isolation_workspace_<RUN_ID>/). Also writes placeholder
TOML files for the redirected paths. NO SLOP_* env vars are set;
src/paths.py reads the overrides from config.toml [paths] (with env var
as fallback if needed).
[C: tests/conftest.py:_ISOLATION_WORKSPACE, src/paths.py:_resolve_path]
as fallback if needed). Also re-initializes the paths singleton so every
getter sees the test-workspace overrides.
[C: tests/conftest.py:_ISOLATION_WORKSPACE, src/paths.py:initialize_paths]
"""
from src import paths as _paths
_paths.reset_resolved()
test_workspace = _ISOLATION_WORKSPACE
@@ -421,14 +421,15 @@ def isolate_workspace(monkeypatch) -> Generator[None, None, None]:
@pytest.fixture(autouse=True)
def reset_paths() -> Generator[None, None, None]:
"""
Autouse fixture that resets the paths global state before each test.
Autouse fixture that resets the paths singleton before each test.
The isolate_workspace fixture re-initializes paths before the test runs,
so reset_paths is a no-op here (PathsConfig is frozen at init time,
the per-getter cache is gone). Kept as a marker for backward compatibility
with test code that asserts the singleton is cleared at test boundaries.
"""
from src import paths
paths.reset_resolved()
yield
paths.reset_resolved()
paths.reset_paths()
@pytest.fixture(autouse=True)
def reset_ai_client() -> Generator[None, None, None]: