Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions litellm/llms/vertex_ai/gemini/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,12 @@ def _pop_and_merge_extra_body(data: RequestBody, optional_params: dict) -> None:
"""Pop extra_body from optional_params and shallow-merge into data, deep-merging dict values."""
extra_body: Optional[dict] = optional_params.pop("extra_body", None)
if extra_body is not None:
data_dict: dict = data # type: ignore[assignment]
for k, v in extra_body.items():
if k in data and isinstance(data[k], dict) and isinstance(v, dict):
data[k].update(v)
if k in data_dict and isinstance(data_dict[k], dict) and isinstance(v, dict):
data_dict[k].update(v)
else:
data[k] = v
data_dict[k] = v


def _transform_request_body(
Expand Down
2 changes: 1 addition & 1 deletion litellm/proxy/_experimental/mcp_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,7 @@ async def handle_streamable_http_mcp(
# Inject masked debug headers when client sends x-litellm-mcp-debug: true
_debug_headers = MCPDebug.maybe_build_debug_headers(
raw_headers=raw_headers,
scope=scope,
scope=dict(scope),
mcp_servers=mcp_servers,
mcp_auth_header=mcp_auth_header,
mcp_server_auth_headers=mcp_server_auth_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,11 @@ async def endpoint_func( # type: ignore
final_query_params.update(query_params)
# When a caller (e.g. bedrock_proxy_route) supplies a pre-built
# body, use it instead of the body parsed from the raw request.
final_custom_body: Optional[dict] = None
if custom_body is not None:
final_custom_body = custom_body
else:
final_custom_body = (
custom_body_data
if isinstance(custom_body_data, dict) or custom_body_data is None
else None
)
elif isinstance(custom_body_data, dict):
final_custom_body = custom_body_data

return await pass_through_request( # type: ignore
request=request,
Expand Down
4 changes: 2 additions & 2 deletions litellm/proxy/vector_store_endpoints/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional
from typing import Any, Dict, Optional

from fastapi import APIRouter, Depends, HTTPException, Request, Response

Expand Down Expand Up @@ -230,7 +230,7 @@ async def vector_store_create(
)

# Get managed vector stores hook
managed_vector_stores = proxy_logging_obj.get_proxy_hook("managed_vector_stores")
managed_vector_stores: Any = proxy_logging_obj.get_proxy_hook("managed_vector_stores")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any annotation erases type safety

get_proxy_hook() returns Optional[CustomLogger] — a well-typed return value. Annotating the result as Any silences mypy but removes all type checking for subsequent usage of managed_vector_stores (e.g., the acreate_vector_store call on line 247 won't be checked). Consider using cast() or a protocol/interface that describes the expected methods instead:

Suggested change
managed_vector_stores: Any = proxy_logging_obj.get_proxy_hook("managed_vector_stores")
managed_vector_stores = proxy_logging_obj.get_proxy_hook("managed_vector_stores")

If the issue is that CustomLogger doesn't declare acreate_vector_store, the proper fix is to add that method to the CustomLogger base class or create a Protocol that describes the expected interface, then use cast() to narrow the type.

if managed_vector_stores is None:
raise HTTPException(
status_code=500,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def transform_chat_completion_response_to_responses_api_response(
previous_response_id=getattr(
chat_completion_response, "previous_response_id", None
),
reasoning=Reasoning(),
reasoning=dict(Reasoning()),
status=LiteLLMCompletionResponsesConfig._map_chat_completion_finish_reason_to_responses_status(
finish_reason
),
Expand All @@ -1516,7 +1516,7 @@ def transform_chat_completion_response_to_responses_api_response(
# Surface provider-specific fields (generic passthrough from any provider)
provider_fields = responses_api_response._hidden_params.get("provider_specific_fields")
if provider_fields:
responses_api_response.provider_specific_fields = provider_fields
setattr(responses_api_response, "provider_specific_fields", provider_fields)

return responses_api_response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def validate_endpoint_configuration(self) -> "ZscalerAIGuardConfigModel":
)

# Check for configuration issues
assert api_base is not None # always set via env default above
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert can be stripped in optimized mode

Using assert for runtime type narrowing is fragile because Python's -O flag strips all assert statements. While the logic guarantees api_base is non-None here (due to the os.getenv default), a safer approach for mypy narrowing would be an if guard or a cast:

Suggested change
assert api_base is not None # always set via env default above
if api_base is None: # always set via env default above; narrow for mypy
api_base = "https://api.us1.zseclipse.net/v1/detection/execute-policy"

is_resolve_policy = api_base.endswith("/resolve-and-execute-policy")
is_execute_policy = api_base.endswith("/execute-policy") and not is_resolve_policy

Expand Down
Loading