Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(scripts): resolve worktree root before relative_to in type_check_gate (#31906)

yuneng-jiangae6dbb4a9bc7
diff --git a/scripts/type_check_gate.py b/scripts/type_check_gate.py
index 256fc433d8d..d3837cc2c0d 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 3faf46c87de..e602bf6e66f 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) == []