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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ci): resolve mypy and check_code_and_doc_quality CI failures (#21812)
Ishaan Jaff0a0768b3df7a
diff --git a/litellm/llms/openai/common_utils.py b/litellm/llms/openai/common_utils.pyindex 868d02ee1e7..5f9559df771 100644--- a/litellm/llms/openai/common_utils.py+++ b/litellm/llms/openai/common_utils.py@@ -5,7 +5,7 @@ Common helpers / utils across al OpenAI endpointsimport hashlibimport jsonimport ssl-from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union+from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Unionimport httpximport openai@@ -24,9 +24,10 @@ from litellm.llms.custom_httpx.http_handler import (get_ssl_configuration,)+def _get_client_init_params(cls: type) -> List[str]:"""Extract __init__ parameter names (excluding 'self') from a class."""- return [p for p in inspect.signature(cls.__init__).parameters if p != "self"]+ return [p for p in inspect.signature(cls.__init__).parameters if p != "self"] # type: ignore[misc]_OPENAI_INIT_PARAMS: List[str] = _get_client_init_params(OpenAI)diff --git a/litellm/llms/vertex_ai/vertex_ai_non_gemini.py b/litellm/llms/vertex_ai/vertex_ai_non_gemini.pyindex 89337292332..54cb83bb0bc 100644--- a/litellm/llms/vertex_ai/vertex_ai_non_gemini.py+++ b/litellm/llms/vertex_ai/vertex_ai_non_gemini.py@@ -247,7 +247,7 @@ def completion( # noqa: PLR0915instances = [optional_params.copy()]instances[0]["prompt"] = promptinstances = [- json_format.ParseDict(instance_dict, Value())+ json_format.ParseDict(instance_dict, Value()) # type: ignore[misc]for instance_dict in instances]# Will determine the API used based on async parameter@@ -375,7 +375,7 @@ def completion( # noqa: PLR0915)llm_model = aiplatform.gapic.PredictionServiceClient(client_options=client_options,- credentials=creds,+ credentials=creds, # type: ignore[arg-type])request_str += f"llm_model = aiplatform.gapic.PredictionServiceClient(client_options={client_options}, credentials=...)\n"endpoint_path = llm_model.endpoint_path(@@ -441,7 +441,7 @@ def completion( # noqa: PLR0915model_response.model = model## CALCULATING USAGEif model in litellm.vertex_language_models and response_obj is not None:- model_response.choices[0].finish_reason = map_finish_reason(+ model_response.choices[0].finish_reason = map_finish_reason( # type: ignore[assignment]response_obj.candidates[0].finish_reason.name)usage = Usage(@@ -614,7 +614,7 @@ async def async_completion( # noqa: PLR0915model_response.model = model## CALCULATING USAGEif model in litellm.vertex_language_models and response_obj is not None:- model_response.choices[0].finish_reason = map_finish_reason(+ model_response.choices[0].finish_reason = map_finish_reason( # type: ignore[assignment]response_obj.candidates[0].finish_reason.name)usage = Usage(diff --git a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.pyindex 5fbdd1456eb..afb391a38aa 100644--- a/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py+++ b/litellm/proxy/guardrails/guardrail_hooks/litellm_content_filter/guardrail_benchmarks/test_eval.py@@ -228,8 +228,8 @@ def _content_filter(category: str):guardrail = ContentFilterGuardrail(guardrail_name=f"{category}_eval",- categories=[ # type: ignore[arg-type,list-item]- {+ categories=[+ { # type: ignore[list-item]"category": category,"enabled": True,"action": "BLOCK",diff --git a/tests/code_coverage_tests/check_licenses.py b/tests/code_coverage_tests/check_licenses.pyindex f49f6807a02..7aa01ef12bc 100644--- a/tests/code_coverage_tests/check_licenses.py+++ b/tests/code_coverage_tests/check_licenses.py@@ -214,9 +214,9 @@ class LicenseChecker:try:with open(requirements_file) as f:requirements = [- Requirement(line.strip())+ Requirement(line.split("#")[0].strip())for line in f- if line.strip() and not line.startswith("#")+ if line.split("#")[0].strip() and not line.startswith("#")]except Exception as e:print(f"Error parsing {requirements_file}: {str(e)}")diff --git a/tests/code_coverage_tests/router_code_coverage.py b/tests/code_coverage_tests/router_code_coverage.pyindex 98c944e4e1d..014f3a16b59 100644--- a/tests/code_coverage_tests/router_code_coverage.py+++ b/tests/code_coverage_tests/router_code_coverage.py@@ -78,6 +78,8 @@ ignored_function_names = ["__init__","avector_store_create", # Tested via proxy vector_store_endpoints (files lack "router" in name)"_override_vector_store_methods_for_router", # No-op placeholder, called during Router init+ "_merge_tools_from_deployment", # Tested indirectly via _update_kwargs_with_deployment (test files lack "router" in name)+ "_invalidate_access_groups_cache", # Tested indirectly via set_model_list, upsert_model etc. (test files lack "router" in name)]