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

This commit is contained in:
mateo-berri 2026-08-05 18:56:50 -07:00
parent 3c808f9c8f
commit 28a277e99e
5 changed files with 10 additions and 26 deletions

View file

@ -3,7 +3,7 @@
"limit": 29204 "limit": 29204
}, },
"reportArgumentType": { "reportArgumentType": {
"limit": 2635 "limit": 2634
}, },
"reportAssignmentType": { "reportAssignmentType": {
"limit": 329 "limit": 329
@ -24,7 +24,7 @@
"limit": 19 "limit": 19
}, },
"reportExplicitAny": { "reportExplicitAny": {
"limit": 9227 "limit": 9226
}, },
"reportFunctionMemberAccess": { "reportFunctionMemberAccess": {
"limit": 7 "limit": 7
@ -105,7 +105,7 @@
"limit": 113 "limit": 113
}, },
"reportUnknownMemberType": { "reportUnknownMemberType": {
"limit": 40340 "limit": 40339
}, },
"reportUnknownParameterType": { "reportUnknownParameterType": {
"limit": 20293 "limit": 20293
@ -117,13 +117,13 @@
"limit": 122 "limit": 122
}, },
"reportUnnecessaryComparison": { "reportUnnecessaryComparison": {
"limit": 703 "limit": 702
}, },
"reportUnnecessaryContains": { "reportUnnecessaryContains": {
"limit": 5 "limit": 5
}, },
"reportUnnecessaryIsInstance": { "reportUnnecessaryIsInstance": {
"limit": 865 "limit": 864
}, },
"reportUntypedBaseClass": { "reportUntypedBaseClass": {
"limit": 72 "limit": 72

View file

@ -574,22 +574,6 @@ class AnthropicMessagesHandler(BaseTranslation):
data: Final = source.get("data") data: Final = source.get("data")
return (data,) if data else () 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( async def _apply_guardrail_responses_to_input(
self, self,
messages: list[dict[str, Any]], messages: list[dict[str, Any]],

View file

@ -130,7 +130,7 @@ def openai_messages_without_tool(
return tuple(m for m in messages if _message_role(m) != "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 return getattr(guardrail_to_apply, "scan_only_tool_results", None) is True

View file

@ -42,7 +42,7 @@
"limit": 81 "limit": 81
}, },
"B010": { "B010": {
"limit": 194 "limit": 192
}, },
"B018": { "B018": {
"limit": 2 "limit": 2

View file

@ -1,6 +1,6 @@
{ {
"LIT001": { "LIT001": {
"limit": 23343 "limit": 23337
}, },
"LIT002": { "LIT002": {
"limit": 27213 "limit": 27213
@ -15,7 +15,7 @@
"limit": 0 "limit": 0
}, },
"LIT006": { "LIT006": {
"limit": 1093 "limit": 1092
}, },
"LIT007": { "LIT007": {
"limit": 0 "limit": 0
@ -27,7 +27,7 @@
"limit": 0 "limit": 0
}, },
"LIT010": { "LIT010": {
"limit": 16802 "limit": 16796
}, },
"LIT011": { "LIT011": {
"limit": 5602 "limit": 5602