diff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.py index e7b80538ab6..7fd05ac7664 100644 --- a/litellm/proxy/auth/auth_utils.py +++ b/litellm/proxy/auth/auth_utils.py @@ -13,7 +13,7 @@ from typing import ( Literal, Protocol, TypeAlias, - cast, # noqa: TID251 # cast-ok: key metadata is an untyped JSON blob, narrowed by TypeAdapter right after + cast, # noqa: TID251 # narrows the untyped key metadata blob in _key_customer_limit_map ) from fastapi import HTTPException, Request, status @@ -1651,7 +1651,7 @@ def get_key_tag_rpm_limit( return None -_CUSTOMER_LIMIT_MAP: Final[TypeAdapter[dict[str, int]]] = TypeAdapter(dict[str, int]) +_CUSTOMER_LIMIT_MAP: Final[TypeAdapter[Mapping[str, int]]] = TypeAdapter(Mapping[str, int]) def _key_customer_limit_map(user_api_key_dict: UserAPIKeyAuth, field: str) -> Mapping[str, int]: diff --git a/litellm/types/proxy/management_endpoints/request_base.py b/litellm/types/proxy/management_endpoints/request_base.py index 6f8cf5b0bfc..326d570e44d 100644 --- a/litellm/types/proxy/management_endpoints/request_base.py +++ b/litellm/types/proxy/management_endpoints/request_base.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import Any # noqa: TID251 # metadata and models stay Any so existing callers keep type-checking from pydantic import ConfigDict, NonNegativeInt, field_validator @@ -52,8 +53,8 @@ class GenerateRequestBase(LiteLLMPydanticObjectBase): model_tpm_limit: dict[object, object] | None = None mcp_rpm_limit: dict[str, int] | None = None tag_rpm_limit: dict[str, int] | None = None - customer_rpm_limit: dict[str, NonNegativeInt] | None = None - customer_tpm_limit: dict[str, NonNegativeInt] | None = None + customer_rpm_limit: Mapping[str, NonNegativeInt] | None = None + customer_tpm_limit: Mapping[str, NonNegativeInt] | None = None guardrails: list[str] | None = None policies: list[str] | None = None prompts: list[str] | None = None