From 447848b88208ea0b014c7903ded2627f9d945bd7 Mon Sep 17 00:00:00 2001 From: arthi-arumugam-git Date: Sat, 8 Aug 2026 14:00:26 +0530 Subject: [PATCH] fix(ollama): annotate the new locals Final to satisfy LIT010 The type-discipline gate counts LIT010 across the tree and fails when a change pushes the total above the base. This branch added six locals without a Final declaration, taking the total to 16804 against a limit of 16802. Annotated, the total is 16798, which is exactly the base. No behaviour changes: every one of the six is bound once and never rebound, which is what Final asserts. The 23 tests in tests/test_litellm/llms/ollama/test_ollama_completion_transformation.py pass unchanged. --- litellm/llms/ollama/completion/transformation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/litellm/llms/ollama/completion/transformation.py b/litellm/llms/ollama/completion/transformation.py index 83f77b1ef62..9157fb13a07 100644 --- a/litellm/llms/ollama/completion/transformation.py +++ b/litellm/llms/ollama/completion/transformation.py @@ -458,7 +458,7 @@ def _prompted_tool_names(prompted_tools: object) -> frozenset[str]: if not isinstance(prompted_tools, list): return frozenset() - schemas = ((tool.get("function") or tool) for tool in prompted_tools if isinstance(tool, dict)) + schemas: Final = ((tool.get("function") or tool) for tool in prompted_tools if isinstance(tool, dict)) return frozenset( schema["name"] for schema in schemas if isinstance(schema, dict) and isinstance(schema.get("name"), str) ) @@ -483,7 +483,7 @@ def _build_tool_call(response_text: str, tool_names: frozenset[str]) -> ChatComp applies to the same body, so it never converts anything that path would leave as content. """ try: - function_call = _OllamaJsonModeToolCall.model_validate_json(response_text) + function_call: Final = _OllamaJsonModeToolCall.model_validate_json(response_text) except ValidationError: return None @@ -525,11 +525,11 @@ class OllamaTextCompletionResponseIterator(BaseModelResponseIterator): return content self.tool_call_buffer += content - stripped = self.tool_call_buffer.lstrip() + stripped: Final = self.tool_call_buffer.lstrip() if not stripped or stripped.startswith("{"): return None - released = self.tool_call_buffer + released: Final = self.tool_call_buffer self.tool_call_buffer = None return released @@ -559,9 +559,9 @@ class OllamaTextCompletionResponseIterator(BaseModelResponseIterator): total_tokens=prompt_eval_count + eval_count, ) - held_back = self.tool_call_buffer + held_back: Final = self.tool_call_buffer self.tool_call_buffer = None - tool_call = _build_tool_call(held_back, self.tool_names) if held_back else None + tool_call: Final = _build_tool_call(held_back, self.tool_names) if held_back else None if tool_call is not None: return GenericStreamingChunk( text="",