mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
fix(mypy): resolve 11 type errors across 8 files
- llms/openai/openai.py + llms/azure/batches/handler.py: add type: ignore[arg-type] for FileExpiresAfter vs OutputExpiresAfter SDK mismatch
- batches/main.py: add type: ignore for dict[str, Any] -> FileExpiresAfter assignment
- llms/openrouter/image_edit/transformation.py: cast value to str before passing to typed methods
- proxy/db/db_transaction_queue/spend_log_cleanup.py: add type: ignore[assignment] for bool | None -> bool
- proxy/management_endpoints/cost_tracking_settings.py: cast base_model to str to match return type
- proxy/guardrails/guardrail_hooks/azure/{text_moderation,prompt_shield}.py: add type: ignore[misc] for TypedDict ** expansion
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
612066a623
commit
161f5e3f2f
8 changed files with 11 additions and 11 deletions
|
|
@ -219,7 +219,7 @@ def create_batch( # noqa: PLR0915
|
|||
extra_body=extra_body,
|
||||
)
|
||||
if output_expires_after is not None:
|
||||
_create_batch_request["output_expires_after"] = output_expires_after
|
||||
_create_batch_request["output_expires_after"] = output_expires_after # type: ignore[typeddict-item]
|
||||
if model is not None:
|
||||
provider_config = ProviderConfigManager.get_provider_batches_config(
|
||||
model=model,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
create_batch_data: CreateBatchRequest,
|
||||
azure_client: Union[AsyncAzureOpenAI, AsyncOpenAI],
|
||||
) -> LiteLLMBatch:
|
||||
response = await azure_client.batches.create(**create_batch_data)
|
||||
response = await azure_client.batches.create(**create_batch_data) # type: ignore[arg-type]
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
def create_batch(
|
||||
|
|
@ -73,7 +73,7 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
return self.acreate_batch( # type: ignore
|
||||
create_batch_data=create_batch_data, azure_client=azure_client
|
||||
)
|
||||
response = cast(Union[AzureOpenAI, OpenAI], azure_client).batches.create(**create_batch_data)
|
||||
response = cast(Union[AzureOpenAI, OpenAI], azure_client).batches.create(**create_batch_data) # type: ignore[arg-type]
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
async def aretrieve_batch(
|
||||
|
|
|
|||
|
|
@ -1938,7 +1938,7 @@ class OpenAIBatchesAPI(BaseLLM):
|
|||
create_batch_data: CreateBatchRequest,
|
||||
openai_client: AsyncOpenAI,
|
||||
) -> LiteLLMBatch:
|
||||
response = await openai_client.batches.create(**create_batch_data)
|
||||
response = await openai_client.batches.create(**create_batch_data) # type: ignore[arg-type]
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
def create_batch(
|
||||
|
|
@ -1974,7 +1974,7 @@ class OpenAIBatchesAPI(BaseLLM):
|
|||
return self.acreate_batch( # type: ignore
|
||||
create_batch_data=create_batch_data, openai_client=openai_client
|
||||
)
|
||||
response = cast(OpenAI, openai_client).batches.create(**create_batch_data)
|
||||
response = cast(OpenAI, openai_client).batches.create(**create_batch_data) # type: ignore[arg-type]
|
||||
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ class OpenRouterImageEditConfig(BaseImageEditConfig):
|
|||
if key == "size":
|
||||
if "image_config" not in mapped_params:
|
||||
mapped_params["image_config"] = {}
|
||||
mapped_params["image_config"]["aspect_ratio"] = self._map_size_to_aspect_ratio(value)
|
||||
mapped_params["image_config"]["aspect_ratio"] = self._map_size_to_aspect_ratio(str(value))
|
||||
elif key == "quality":
|
||||
image_size = self._map_quality_to_image_size(value)
|
||||
image_size = self._map_quality_to_image_size(str(value))
|
||||
if image_size:
|
||||
if "image_config" not in mapped_params:
|
||||
mapped_params["image_config"] = {}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class SpendLogCleanup:
|
|||
|
||||
# If we have a pod lock manager, try to acquire the lock
|
||||
if self.pod_lock_manager and self.pod_lock_manager.redis_cache:
|
||||
lock_acquired = await self.pod_lock_manager.acquire_lock(
|
||||
lock_acquired = await self.pod_lock_manager.acquire_lock( # type: ignore[assignment]
|
||||
cronjob_id=SPEND_LOG_CLEANUP_JOB_NAME,
|
||||
)
|
||||
verbose_proxy_logger.info(
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class AzureContentSafetyPromptShieldGuardrail(AzureGuardrailBase, CustomGuardrai
|
|||
"text:shieldPrompt", cast(dict, request_body)
|
||||
)
|
||||
|
||||
last_response = AzurePromptShieldGuardrailResponse(**response_json)
|
||||
last_response = AzurePromptShieldGuardrailResponse(**response_json) # type: ignore[misc]
|
||||
|
||||
if last_response["userPromptAnalysis"].get("attackDetected"):
|
||||
verbose_proxy_logger.warning(
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class AzureContentSafetyTextModerationGuardrail(AzureGuardrailBase, CustomGuardr
|
|||
"text:analyze", cast(dict, request_body)
|
||||
)
|
||||
|
||||
chunk_response = AzureTextModerationGuardrailResponse(**response_json)
|
||||
chunk_response = AzureTextModerationGuardrailResponse(**response_json) # type: ignore[misc]
|
||||
|
||||
# For multi-chunk texts the callers only see the final response,
|
||||
# so we must check every intermediate chunk here to avoid silently
|
||||
|
|
|
|||
|
|
@ -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), custom_llm_provider
|
||||
|
||||
resolved_model = litellm_params.get("model")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue