fix(types): address type-safety issues from mypy PR review

- CreateBatchRequest.output_expires_after: drop Optional since total=False
  already makes the key absent-or-present; Optional[T] incorrectly allowed
  the key to exist with value None, which is incompatible with the OpenAI
  SDK's OutputExpiresAfter | NotGiven expectation on batches.create()
- cost_tracking_settings._resolve_model_for_cost_lookup: replace implicit
  object-to-str returns with explicit str() calls so the function is safe
  even if the surrounding truthiness guards are later weakened

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Julio Quinteros
2026-03-05 07:11:31 -03:00
co-authored by Claude Sonnet 4.6
parent 9a13c76e2f
commit c1076de5bd
2 changed files with 3 additions and 3 deletions
@@ -67,7 +67,7 @@ def _resolve_model_for_cost_lookup(model: str) -> Tuple[str, Optional[str]]:
f"Resolved model '{model}' to base_model '{base_model}' from router"
)
custom_llm_provider = litellm_params.get("custom_llm_provider")
return base_model, custom_llm_provider
return str(base_model), str(custom_llm_provider) if custom_llm_provider is not None else None
resolved_model = litellm_params.get("model")
@@ -76,7 +76,7 @@ def _resolve_model_for_cost_lookup(model: str) -> Tuple[str, Optional[str]]:
f"Resolved model '{model}' to '{resolved_model}' from router"
)
custom_llm_provider = litellm_params.get("custom_llm_provider")
return resolved_model, custom_llm_provider
return str(resolved_model), str(custom_llm_provider) if custom_llm_provider is not None else None
except Exception as e:
verbose_proxy_logger.debug(
f"Could not resolve model '{model}' from router: {e}"
+1 -1
View File
@@ -424,7 +424,7 @@ class CreateBatchRequest(TypedDict, total=False):
endpoint: Literal["/v1/chat/completions", "/v1/embeddings", "/v1/completions"]
input_file_id: str
metadata: Optional[Dict[str, str]]
output_expires_after: Optional[FileExpiresAfter]
output_expires_after: FileExpiresAfter
extra_headers: Optional[Dict[str, str]]
extra_body: Optional[Dict[str, str]]
timeout: Optional[float]