mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
fix(scripts): resolve worktree root before relative_to in type_check_gate (#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
This commit is contained in:
parent
34039dfe94
commit
ae6dbb4a9b
2 changed files with 16 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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) == []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue