From b9888ffd89797183088b0caace090b21eb042b56 Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Wed, 1 Jul 2026 13:34:08 -0700 Subject: [PATCH] fix(scripts): resolve worktree root before relative_to in type_check_gate On macOS, tempfile.mkdtemp returns a path under /var/folders, a symlink to /private/var. The base pass in type_check_gate.py resolved each diagnostic path (yielding /private/var/...) but not the worktree root, so relative_to raised ValueError for every diagnostic, base counts came back empty, and the vacuous-run guard failed every local make lint-basedpyright run. type_discipline_gate.py already resolves root the same way; ruff_strict_gate.py counts rule codes without touching worktree paths, so it is unaffected. CI runs Linux where the temp dir is not a symlink, which is why this only bit local macOS runs --- scripts/type_check_gate.py | 2 +- tests/test_litellm/test_type_check_gate.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/type_check_gate.py b/scripts/type_check_gate.py index 256fc433d8d7..d3837cc2c0d3 100644 --- a/scripts/type_check_gate.py +++ b/scripts/type_check_gate.py @@ -63,7 +63,7 @@ def _to_relative(raw: str, root: Path) -> str | None: path = Path(raw) absolute = path if path.is_absolute() else root / path try: - return absolute.resolve().relative_to(root).as_posix() + return absolute.resolve().relative_to(root.resolve()).as_posix() except ValueError: return None diff --git a/tests/test_litellm/test_type_check_gate.py b/tests/test_litellm/test_type_check_gate.py index 3faf46c87de6..e602bf6e66f0 100644 --- a/tests/test_litellm/test_type_check_gate.py +++ b/tests/test_litellm/test_type_check_gate.py @@ -54,6 +54,21 @@ def test_paths_outside_repo_are_skipped(): assert gate.count_basedpyright(payload) == {} +def test_symlinked_root_keeps_diagnostics_in_tree(tmp_path): + real = tmp_path / "real" + real.mkdir() + link = tmp_path / "link" + link.symlink_to(real) + payload = json.dumps( + { + "generalDiagnostics": [ + _bpr(link / "litellm" / "x.py", "error", "reportArgumentType") + ] + } + ) + assert gate.count_basedpyright(payload, root=link) == {"reportArgumentType": 1} + + def test_at_or_under_ceiling_passes(): budget = {"no-any-return": {"limit": 5}} assert gate.evaluate({"no-any-return": 5}, {}, budget) == []