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: preserve Python 3.10 harness compatibility

Yujong Lee6675e1fd9c5a
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json
index dc51a44b5fc..1b0650c70d8 100644
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@ -18,7 +18,7 @@
"limit": 40
},
"reportDeprecated": {
- "limit": 210
+ "limit": 209
},
"reportDuplicateImport": {
"limit": 19
@@ -45,7 +45,7 @@
"limit": 24
},
"reportInvalidTypeForm": {
- "limit": 32
+ "limit": 30
},
"reportInvalidTypeVarUse": {
"limit": 2
@@ -105,13 +105,13 @@
"limit": 109
},
"reportUnknownMemberType": {
- "limit": 38311
+ "limit": 38309
},
"reportUnknownParameterType": {
- "limit": 19624
+ "limit": 19622
},
"reportUnknownVariableType": {
- "limit": 29847
+ "limit": 29846
},
"reportUnnecessaryCast": {
"limit": 111
diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json
index 8d5fc365d1d..4aac1756af4 100644
--- a/ruff-strict-budget.json
+++ b/ruff-strict-budget.json
@@ -9,7 +9,7 @@
"limit": 809
},
"ANN201": {
- "limit": 2000
+ "limit": 1999
},
"ANN202": {
"limit": 835
@@ -87,7 +87,7 @@
"limit": 2
},
"DTZ003": {
- "limit": 25
+ "limit": 24
},
"DTZ005": {
"limit": 233
diff --git a/test-quality-budget.json b/test-quality-budget.json
index 281c17748ee..7ca563d25af 100644
--- a/test-quality-budget.json
+++ b/test-quality-budget.json
@@ -21,6 +21,6 @@
"limit": 117
},
"TQ008": {
- "limit": 11069
+ "limit": 11003
}
}
diff --git a/tests/rust-python-harness/shared/reporting/models.py b/tests/rust-python-harness/shared/reporting/models.py
index f78141fa552..1ebba6c9793 100644
--- a/tests/rust-python-harness/shared/reporting/models.py
+++ b/tests/rust-python-harness/shared/reporting/models.py
@@ -5,7 +5,9 @@ from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from time import monotonic
-from typing import TYPE_CHECKING, Final, Literal, TypeAlias, assert_never
+from typing import TYPE_CHECKING, Final, Literal, TypeAlias
+
+from typing_extensions import assert_never
if TYPE_CHECKING:
from .strategy import CaseSpec, StrategyDefinition
diff --git a/tests/rust-python-harness/shared/reporting/rendering.py b/tests/rust-python-harness/shared/reporting/rendering.py
index 217caa48526..109f1e6cc1d 100644
--- a/tests/rust-python-harness/shared/reporting/rendering.py
+++ b/tests/rust-python-harness/shared/reporting/rendering.py
@@ -2,7 +2,9 @@ from __future__ import annotations
from collections.abc import Sequence
from dataclasses import dataclass
-from typing import Final, Protocol, assert_never
+from typing import Final, Protocol
+
+from typing_extensions import assert_never
from .models import CaseDisposition, CaseResult
diff --git a/tests/rust-python-harness/shared/tracing/profiler.py b/tests/rust-python-harness/shared/tracing/profiler.py
index ead856ee58f..abfb6a2425d 100644
--- a/tests/rust-python-harness/shared/tracing/profiler.py
+++ b/tests/rust-python-harness/shared/tracing/profiler.py
@@ -80,6 +80,17 @@ def _qualified_name(frame: FrameType) -> str:
native: Final = getattr(code, "co_qualname", None)
if isinstance(native, str):
return native
+ enclosing: Final = next(
+ (
+ name
+ for ancestor in _frame_ancestors(frame)
+ for declared_code, name in _declared_functions(ancestor.f_locals, frozenset())
+ if declared_code is code
+ ),
+ None,
+ )
+ if enclosing is not None:
+ return enclosing
module_name: Final = frame.f_globals.get("__name__")
if not isinstance(module_name, str):
return code.co_name
diff --git a/tests/rust-python-harness/shared/tracing/pytest_usage.py b/tests/rust-python-harness/shared/tracing/pytest_usage.py
index 58af174df38..285514a5239 100644
--- a/tests/rust-python-harness/shared/tracing/pytest_usage.py
+++ b/tests/rust-python-harness/shared/tracing/pytest_usage.py
@@ -11,6 +11,7 @@ import tempfile
import warnings
from collections.abc import Generator, Sequence
from pathlib import Path
+from types import CodeType
from typing import TYPE_CHECKING, Final
from pluggy import HookimplMarker
@@ -62,9 +63,12 @@ class PythonFunctionReference(BaseModel):
value: object = importlib.import_module(self.module)
for component in self.qualname.split("."):
value = getattr(value, component)
+ if not callable(value):
+ raise ValueError(f"Python function is not callable: {self.module}:{self.qualname}")
function: Final = inspect.unwrap(value)
code: Final = getattr(function, "__code__", None)
- if code is None:
+ qualname: Final = getattr(function, "__qualname__", None)
+ if not isinstance(code, CodeType) or not isinstance(qualname, str):
raise ValueError(f"Python function has no code object: {self.module}:{self.qualname}")
source: Final = Path(code.co_filename).resolve()
try:
@@ -74,7 +78,7 @@ class PythonFunctionReference(BaseModel):
return PythonFunctionIdentity(
file=relative.as_posix(),
line=code.co_firstlineno,
- qualname=code.co_qualname,
+ qualname=qualname,
)
diff --git a/tests/rust-python-harness/strategies/trace_parity/runner.py b/tests/rust-python-harness/strategies/trace_parity/runner.py
index ef373a6f2f6..b78a3c7da3f 100644
--- a/tests/rust-python-harness/strategies/trace_parity/runner.py
+++ b/tests/rust-python-harness/strategies/trace_parity/runner.py
@@ -165,9 +165,10 @@ def run_trace_cases(
) -> tuple[int, HarnessRun]:
selected_scenarios: Final = frozenset(runner_args)
run: Final = HarnessRun.from_cases(cases)
- bridge_error: Final = ensure_trace_bridge(repo_root)
+ runnable_cases: Final = tuple(case for case in cases if isinstance(case.spec, ModuleCaseSpec))
+ bridge_error: Final = ensure_trace_bridge(repo_root) if runnable_cases else None
if bridge_error is not None:
- for harness_case in cases:
+ for harness_case in runnable_cases:
_record_setup_failure(run, harness_case, bridge_error, "bridge")
run.finished_at = monotonic()
on_update(run)
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index ba871b5f69b..094b9749d98 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -33,6 +33,6 @@
"limit": 5514
},
"LIT012": {
- "limit": 4488
+ "limit": 4487
}
}