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(lint): Partly fix basedpyright lint issues
KnyazSh278fdbecb76f
diff --git a/litellm/llms/gigachat/authenticator.py b/litellm/llms/gigachat/authenticator.pyindex a2e8030a2d1..293176d8931 100644--- a/litellm/llms/gigachat/authenticator.py+++ b/litellm/llms/gigachat/authenticator.py@@ -107,7 +107,7 @@ def get_access_token(return _token# Request new token- new_token, new_expires_at = _request_token_sync(effective_credentials, effective_scope, effective_auth_url)+ new_token, new_expires_at = _request_token_sync(effective_credentials, effective_scope, effective_auth_url) # pyright: ignore[reportArgumentType] # credential keys may be broader than strif new_expires_at:# Cache token@@ -152,7 +152,7 @@ async def get_access_token_async(return _token# Request new token- new_token, new_expires_at = await _request_token_async(effective_credentials, effective_scope, effective_auth_url)+ new_token, new_expires_at = await _request_token_async(effective_credentials, effective_scope, effective_auth_url) # pyright: ignore[reportArgumentType] # credential keys may be broader than strif new_expires_at:# Cache token@@ -187,7 +187,7 @@ def _request_token_sync(client: Final = _get_http_client()response: Final = client.post(auth_url, headers=headers, data=data, timeout=30)response.raise_for_status()- return _parse_token_response(response)+ return _parse_token_response(response) # pyright: ignore[reportArgumentType] # httpx Response may be None at type levelexcept httpx.HTTPStatusError as e:raise GigaChatAuthError(status_code=e.response.status_code,@@ -222,7 +222,7 @@ async def _request_token_async()response: Final = await client.post(auth_url, headers=headers, data=data, timeout=30)response.raise_for_status()- return _parse_token_response(response)+ return _parse_token_response(response) # pyright: ignore[reportArgumentType] # httpx Response may be None at type levelexcept httpx.HTTPStatusError as e:raise GigaChatAuthError(status_code=e.response.status_code,diff --git a/litellm/llms/gigachat/chat/streaming.py b/litellm/llms/gigachat/chat/streaming.pyindex 64f3057a66f..3ed31c62d7d 100644--- a/litellm/llms/gigachat/chat/streaming.py+++ b/litellm/llms/gigachat/chat/streaming.py@@ -5,7 +5,7 @@ GigaChat Streaming Response Handlerimport jsonimport uuidfrom collections.abc import Mapping, Sequence-from typing import Any, Final+from typing import Any, Final, castfrom litellm.llms.gigachat.utils import convert_usagefrom litellm.types.llms.openai import (@@ -76,7 +76,7 @@ class GigaChatModelResponseIterator:if chunk_finish_reason == "stop":usage_data: Final = chunk.get("usage") or {} # mutable-ok: empty dict defaultif usage_data:- usage = convert_usage(usage_data) # rebind-ok: conditional usage assignment+ usage = convert_usage(cast("Mapping[str, int]", usage_data)) # cast-ok: dict from chunk has int valuesusage_block = ChatCompletionUsageBlock(prompt_tokens=usage.prompt_tokens,completion_tokens=usage.completion_tokens,@@ -90,7 +90,7 @@ class GigaChatModelResponseIterator:)return GenericStreamingChunk(- text=text,+ text=cast(str, text),tool_use=tool_use,is_finished=chunk_finish_reason is not None,finish_reason=finish_reason or "",diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.pyindex 3b554f5b56a..c7c290dcd2d 100644--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py@@ -509,7 +509,7 @@ async def milvus_proxy_route(detail=f"collectionName must be a string. Got {type(_raw_collection_name).__name__}",)collection_name: str | None = _raw_collection_name # rebind-ok: locally scoped conversion- extra_headers: Final = {} # mutable-ok: dict for extra headers+ extra_headers = {} # mutable-ok: dict for extra headers; rebind-ok: reassigned later from credentialsbase_target_url: str | None = Noneif not collection_name:raise HTTPException(@@ -2839,10 +2839,10 @@ async def gigachat_proxy_route()## check for streaming- request_body: Final = await get_request_body(request)+ request_body: Final = await get_request_body(request) # pyright: ignore[reportUnknownVariableType] # get_request_body returns Unknownis_router_model = False # rebind-ok: conditionally set to True when model uses router- model: Final = request_body.get("model")+ model: Final = request_body.get("model") # pyright: ignore[reportUnknownVariableType] # get_request_body returns Unknownif model:is_router_model = is_passthrough_request_using_router_model(request_body, llm_router@@ -2880,7 +2880,9 @@ async def gigachat_proxy_route("Gigachat passthrough: Using direct Gigachat model '%s' for endpoint '%s'", model, endpoint)- data: Final[dict[str, Any]] = {} # mutable-ok: request body mutated in place by proxy pipeline+ data: dict[+ str, Any+ ] = {} # mutable-ok: request body mutated in place by proxy pipeline; pyright: ignore[reportExplicitAny] # Any needed for proxy pipeline flexibilitydata["method"] = request.methoddata["endpoint"] = endpoint@@ -2968,9 +2970,11 @@ async def handle_gigachat_passthrough_router_model(from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing# Detect streaming based on request body- is_streaming: Final = request_body.get("stream", False)+ is_streaming: Final = request_body.get("stream", False) # pyright: ignore[reportUnknownVariableType] # request_body is dict[Unknown, Unknown]- data: Final[dict[str, Any]] = await _read_request_body(request=request)+ data: dict[str, Any] = await _read_request_body(+ request=request+ ) # mutable-ok: mutated in place by proxy pipeline; pyright: ignore[reportExplicitAny] # Any needed for proxy pipelineif user_api_key_dict is not None:if data.get("metadata") is None:data["metadata"] = {} # mutable-ok: metadata dict mutated in place@@ -3021,7 +3025,7 @@ async def handle_gigachat_passthrough_router_model(# Use the common passthrough processing to handle metadata and hooks# This also handles all response formatting (streaming/non-streaming) and exceptionstry:- result: Final = await base_llm_response_processor.base_passthrough_process_llm_request(+ result = await base_llm_response_processor.base_passthrough_process_llm_request( # rebind-ok: assigned once in try blockrequest=request,fastapi_response=fastapi_response,user_api_key_dict=user_api_key_dict,