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]

refactor(guardrails): drop dead tool extraction and an Any annotation, ratchet lint budgets

mateo-berri28a277e99e28
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json
index 27d96e415fd..8a5c78c1f6c 100644
--- a/basedpyright-code-budget.json
+++ b/basedpyright-code-budget.json
@@ -3,7 +3,7 @@
"limit": 29204
},
"reportArgumentType": {
- "limit": 2635
+ "limit": 2634
},
"reportAssignmentType": {
"limit": 329
@@ -24,7 +24,7 @@
"limit": 19
},
"reportExplicitAny": {
- "limit": 9227
+ "limit": 9226
},
"reportFunctionMemberAccess": {
"limit": 7
@@ -105,7 +105,7 @@
"limit": 113
},
"reportUnknownMemberType": {
- "limit": 40340
+ "limit": 40339
},
"reportUnknownParameterType": {
"limit": 20293
@@ -117,13 +117,13 @@
"limit": 122
},
"reportUnnecessaryComparison": {
- "limit": 703
+ "limit": 702
},
"reportUnnecessaryContains": {
"limit": 5
},
"reportUnnecessaryIsInstance": {
- "limit": 865
+ "limit": 864
},
"reportUntypedBaseClass": {
"limit": 72
diff --git a/litellm/llms/anthropic/chat/guardrail_translation/handler.py b/litellm/llms/anthropic/chat/guardrail_translation/handler.py
index c25fa624f7f..60424fb78b5 100644
--- a/litellm/llms/anthropic/chat/guardrail_translation/handler.py
+++ b/litellm/llms/anthropic/chat/guardrail_translation/handler.py
@@ -574,22 +574,6 @@ class AnthropicMessagesHandler(BaseTranslation):
data: Final = source.get("data")
return (data,) if data else ()
- def _extract_input_tools(
- self,
- tools: list[dict[str, Any]],
- tools_to_check: list[ChatCompletionToolParam],
- ) -> None:
- """
- Extract tools from a message.
- """
- ## CHECK FOR TOOLS
- if tools is not None and isinstance(tools, list):
- # TRANSFORM ANTHROPIC TOOLS TO OPENAI TOOLS
- openai_tools: Final = self.adapter.translate_anthropic_tools_to_openai(
- tools=cast(list[AllAnthropicToolsValues], tools)
- )
- tools_to_check.extend(openai_tools)
-
async def _apply_guardrail_responses_to_input(
self,
messages: list[dict[str, Any]],
diff --git a/litellm/llms/base_llm/guardrail_translation/utils.py b/litellm/llms/base_llm/guardrail_translation/utils.py
index fcd504fee2f..432ac64b456 100644
--- a/litellm/llms/base_llm/guardrail_translation/utils.py
+++ b/litellm/llms/base_llm/guardrail_translation/utils.py
@@ -130,7 +130,7 @@ def openai_messages_without_tool(
return tuple(m for m in messages if _message_role(m) != "tool")
-def effective_scan_only_tool_results_for_guardrail(guardrail_to_apply: Any) -> bool:
+def effective_scan_only_tool_results_for_guardrail(guardrail_to_apply: object) -> bool:
return getattr(guardrail_to_apply, "scan_only_tool_results", None) is True
diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json
index 421b424757b..ea20ac97e07 100644
--- a/ruff-strict-budget.json
+++ b/ruff-strict-budget.json
@@ -42,7 +42,7 @@
"limit": 81
},
"B010": {
- "limit": 194
+ "limit": 192
},
"B018": {
"limit": 2
diff --git a/type-discipline-budget.json b/type-discipline-budget.json
index e26ce54ede7..37964c27657 100644
--- a/type-discipline-budget.json
+++ b/type-discipline-budget.json
@@ -1,6 +1,6 @@
{
"LIT001": {
- "limit": 23343
+ "limit": 23337
},
"LIT002": {
"limit": 27213
@@ -15,7 +15,7 @@
"limit": 0
},
"LIT006": {
- "limit": 1093
+ "limit": 1092
},
"LIT007": {
"limit": 0
@@ -27,7 +27,7 @@
"limit": 0
},
"LIT010": {
- "limit": 16802
+ "limit": 16796
},
"LIT011": {
"limit": 5602