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(typing): bring reportReturnType back under the basedpyright budget (#31103)
Mateo Wang23808c2a094d
diff --git a/litellm/main.py b/litellm/main.pyindex 1d75766c7e6..4fade2ac4b0 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -5044,9 +5044,7 @@ def completion( # type: ignoreif LiteLLM_Proxy_MCP_Handler._should_use_litellm_mcp_gateway(tools=tools_for_mcp):- # Return coroutine - acompletion will await it- # completion() can return a coroutine when MCP tools are present, which acompletion() awaits- return acompletion_with_mcp( # type: ignore[return-value]+ return acompletion_with_mcp( # pyright: ignore[reportReturnType] # MCP path returns a coroutine that acompletion() awaits; completion()'s sync return type omits itmodel=model,messages=messages,functions=functions,@@ -5218,12 +5216,16 @@ def completion( # type: ignorelogging: LiteLLMLoggingObj = cast(LiteLLMLoggingObj, litellm_logging_obj)fallbacks = fallbacks or litellm.model_fallbacksif fallbacks is not None:- return completion_with_fallbacks(**args)+ return completion_with_fallbacks( # pyright: ignore[reportReturnType] # fallback runner is untyped; resolves to ModelResponse|CustomStreamWrapper at runtime+ **args+ )if model_list is not None:deployments = [m["litellm_params"] for m in model_list if m["model_name"] == model]- return litellm.batch_completion_models(deployments=deployments, **args)+ return litellm.batch_completion_models( # pyright: ignore[reportReturnType] # batch path returns a list of responses, outside completion()'s single-response return type+ deployments=deployments, **args+ )if litellm.model_alias_map and model in litellm.model_alias_map:model = litellm.model_alias_map[model@@ -5545,7 +5547,7 @@ def completion( # type: ignoreelse:optional_params["reasoning_effort"] = {"summary": rs_val}- return responses_api_bridge.completion(+ return responses_api_bridge.completion( # pyright: ignore[reportReturnType] # bridge returns a coroutine on the acompletion path; awaited by the async callermodel=model,messages=messages,headers=headers,