From c743b2ffbced0d6e7781269d5d645d18ae7acd90 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Thu, 15 Oct 2026 02:29:36 +0800 Subject: [PATCH] refactor: remove dead direct AI completion helpers Co-Authored-By: Codex --- src/quant_strategy_plugins/ai_audit.py | 13 ------------- tests/test_ai_audit.py | 4 ++-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/quant_strategy_plugins/ai_audit.py b/src/quant_strategy_plugins/ai_audit.py index fe79792..cfcd5c7 100644 --- a/src/quant_strategy_plugins/ai_audit.py +++ b/src/quant_strategy_plugins/ai_audit.py @@ -374,23 +374,10 @@ def _llm_via_gateway(prompt: str, model: str, provider: str, timeout_seconds: fl raise AiAuditError("ai_gateway_request_failed") from None -def _llm_direct(prompt: str, model: str, provider: str, timeout_seconds: float) -> str: - del prompt, model, provider, timeout_seconds - raise AiAuditError("direct_ai_completion_forbidden") -def _codex_exec_direct(prompt: str, timeout_seconds: float) -> str: - del prompt, timeout_seconds - raise AiAuditError("direct_ai_completion_forbidden") -def _codex_exec_completion( - endpoint: AiAuditEndpoint, - messages: Sequence[Mapping[str, str]], - timeout_seconds: float, -) -> str: - del endpoint, messages, timeout_seconds - raise AiAuditError("direct_ai_completion_forbidden") def _extract_json_object(value: str | Mapping[str, Any]) -> dict[str, Any]: diff --git a/tests/test_ai_audit.py b/tests/test_ai_audit.py index 305f202..d542cf9 100644 --- a/tests/test_ai_audit.py +++ b/tests/test_ai_audit.py @@ -369,7 +369,7 @@ def execute(self, *_args, **_kwargs): ), ) direct_calls: list[str] = [] - monkeypatch.setattr(ai_audit, direct_fallback, lambda *_args: direct_calls.append("direct") or "{}") + monkeypatch.setattr(ai_audit, direct_fallback, lambda *_args: direct_calls.append("direct") or "{}", raising=False) with pytest.raises(AiAuditError, match="ai_gateway_request_failed") as exc_info: if gateway_call is _llm_via_gateway: @@ -391,7 +391,7 @@ def execute(self, *_args, **_kwargs): def test_gateway_client_import_failure_never_uses_direct_fallback(monkeypatch, gateway_call, direct_fallback) -> None: monkeypatch.setitem(sys.modules, "ai_gateway_client", None) direct_calls: list[str] = [] - monkeypatch.setattr(ai_audit, direct_fallback, lambda *_args: direct_calls.append("direct") or "{}") + monkeypatch.setattr(ai_audit, direct_fallback, lambda *_args: direct_calls.append("direct") or "{}", raising=False) with pytest.raises(AiAuditError, match="ai_gateway_client_unavailable"): if gateway_call is _llm_via_gateway: