fix(scripts): resolve worktree root before relative_to in type_check_gate - #31906
Conversation
…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
…itellm_/ecstatic-ramanujan-97f9c8
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryFixes a
Confidence Score: 5/5The change is isolated to a developer tooling script and its test; no production code is touched. The fix is a single No files require special attention.
|
| Filename | Overview |
|---|---|
| scripts/type_check_gate.py | Single-character fix in _to_relative: adds .resolve() on root so both sides of relative_to are symlink-resolved, matching the already-resolved diagnostic path. Correct and minimal. |
| tests/test_litellm/test_type_check_gate.py | Adds test_symlinked_root_keeps_diagnostics_in_tree which builds an explicit symlinked root via tmp_path, exercising the bug on Linux CI without requiring the macOS /var symlink. All existing tests are untouched. |
Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
ae6dbb4
into
litellm_internal_staging
…gate (BerriAI#31906) 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
…gate (BerriAI#31906) 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
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
The failure mechanism, reproduced on macOS:
Before the fix, every local
make lint-basedpyrighton a Mac died with "basedpyright produced no errors for the base tree ... refusing to blame this change for it". After the fix, with no TMPDIR workaround:The new regression test fails on the old code and passes with the fix:
Type
🐛 Bug Fix
Changes
On macOS,
tempfile.mkdtemp()returns a path under/var/folders/..., which is a symlink to/private/var/.... The base pass ofscripts/type_check_gate.pyruns basedpyright in a temp worktree there, and_to_relativeresolved each diagnostic path (yielding/private/var/...) but not the worktree root, sorelative_toraisedValueErrorfor every diagnostic. Every base diagnostic was dropped, base counts came back empty, and the vacuous-run guard failed the run. Sincemake pre-commitincludes this gate for anylitellm/Python change, it always failed locally on a Mac. CI runs Linux where the temp dir is not a symlink, so it never saw thisThe fix resolves the root as well:
absolute.resolve().relative_to(root.resolve()). The sibling gates are fine;scripts/type_discipline_gate.pyalready resolves root for exactly this reason andscripts/ruff_strict_gate.pycounts rule codes straight from ruff JSON without computing worktree-relative pathsThe regression test builds an explicit symlinked root instead of relying on the macOS
/varsymlink, so it exercises the bug on Linux CI too