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]

Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_gate_owns_basedpyright_heap

mateo-berri5bf92466678d
diff --cc scripts/type_check_gate.py
index 1bce746b5e2,e35baa99374..31401addedf
--- a/scripts/type_check_gate.py
+++ b/scripts/type_check_gate.py
@@@ -116,29 -107,25 +116,48 @@@ def _run(cmd: list[str], cwd: Path = RE
return proc.stdout
+def node_options_with_heap(base_env: Mapping[str, str]) -> str:
+ return f"{base_env.get('NODE_OPTIONS', '')} {NODE_HEAP_OPTION}".strip()
+
+
+def run_basedpyright(cwd: Path = REPO_ROOT) -> str:
+ """One basedpyright pass over `cwd` with the raised node heap exported.
+
+ Exit 0 (clean) and 1 (errors found) are both output-bearing runs; anything
+ else is a crash and fails loudly instead of reading as zero errors."""
+ exe = shutil.which("basedpyright") or "basedpyright"
+ proc = subprocess.run(
+ [exe, "--outputjson"],
+ cwd=cwd,
+ capture_output=True,
+ text=True,
+ env={**os.environ, "NODE_OPTIONS": node_options_with_heap(os.environ)},
+ )
+ if proc.returncode not in (0, 1):
+ sys.stderr.write(proc.stderr)
+ raise SystemExit(f"basedpyright exited {proc.returncode}")
+ return proc.stdout
+
+
+ def resolve_base_point(base_ref: str, cwd: Path = REPO_ROOT) -> str:
+ """The snapshot commit base counts are measured at: merge-base(base_ref, HEAD),
+ made aware of an in-progress merge. Mid-merge, HEAD is still the pre-merge tip,
+ so its merge-base is the old branch point and every violation the base gained
+ since then would be blamed on this change. While MERGE_HEAD exists, prefer
+ merge-base(base_ref, MERGE_HEAD) whenever it is the newer of the two."""
+ head_point: Final = _run(["git", "merge-base", base_ref, "HEAD"], cwd=cwd).strip()
+ if not head_point:
+ return base_ref
+ merge_head: Final = _run(["git", "rev-parse", "--verify", "--quiet", "MERGE_HEAD"], cwd=cwd).strip()
+ if not merge_head:
+ return head_point
+ merge_point: Final = _run(["git", "merge-base", base_ref, merge_head], cwd=cwd).strip()
+ if not merge_point:
+ return head_point
+ older: Final = _run(["git", "merge-base", head_point, merge_point], cwd=cwd).strip()
+ return merge_point if older == head_point else head_point
+
+
@contextlib.contextmanager
def _temp_worktree(ref: str) -> Iterator[Path]:
parent = Path(tempfile.mkdtemp(prefix="bpr_base_"))
diff --cc tests/test_litellm/test_type_check_gate.py
index 08813d5b0b0,cce980a1c3d..0a9b160d981
--- a/tests/test_litellm/test_type_check_gate.py
+++ b/tests/test_litellm/test_type_check_gate.py
@@@ -1,6 -1,6 +1,7 @@@
import importlib.util
import json
+import os
+ import subprocess
from pathlib import Path
_MODULE_PATH = Path(__file__).resolve().parents[2] / "scripts" / "type_check_gate.py"