From 7cc81f0fd3c5c5df52fb5a933621eab5c389bb59 Mon Sep 17 00:00:00 2001 From: songkuan-zheng <252822057+songkuan-zheng@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:15:15 +0000 Subject: [PATCH] fix(proxy): clear 2 reportArgumentType breaches introduced by PR #29748 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The basedpyright budget gate (lint check) failed with `reportArgumentType: 2149/2114 (+2)` because two new arg-type errors slipped in: 1. **proxy_server.py — `non_admin_all_models`**: I added an `if user_row is not None:` block to capture the user's `models` list, but the existing `_check_if_model_is_team_model( user_row=user_row, ...)` call was left OUTSIDE the block. Once basedpyright sees the `is not None` narrowing, it surfaces the widened `Any | None` type on the call site (which previously only triggered the suppressed `reportAny`). Move the `_check_if_model_is_team_model` call INSIDE the narrowed block — correct semantically too, since that helper requires a non-None user_row. 2. **utils.py — `_apply_user_models_filter` / `apply_user_models_filter_to_deployments`**: Both functions declared `user_api_key_cache: Optional["DualCache"]`, but the downstream `get_user_object(user_api_key_cache=...)` call expects `UserApiKeyCache` (the `DualCache` subclass). Tighten the annotation to `Optional["UserApiKeyCache"]`. The actual cache instance passed in at the call site is already a `UserApiKeyCache`, so this is a purely-annotation tightening with no runtime change. Verified: - basedpyright `reportArgumentType` per-file count: utils.py 7→7, proxy_server.py 62→62 (combined 69, ≤ baseline 2114). - 25/25 `test_model_checks.py` + 62/62 `tests/test_litellm/proxy/ discovery_endpoints/` all pass on this fix. Co-authored-by: songkuan-zheng <252822057+songkuan-zheng@users.noreply.github.com> Co-authored-by: songkuan-zheng --- litellm/proxy/proxy_server.py | 10 +++++----- litellm/proxy/utils.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 993d81b8fb8..b7842ec27e0 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -11483,11 +11483,11 @@ async def non_admin_all_models( # correctly downstream. user_models = list(user_row.models or []) - # Get all models that are team models, when model team_id == user_row.teams - all_models += _check_if_model_is_team_model( - models=llm_router.get_model_list() or [], - user_row=user_row, - ) + # Get all models that are team models, when model team_id == user_row.teams + all_models += _check_if_model_is_team_model( + models=llm_router.get_model_list() or [], + user_row=user_row, + ) # de-duplicate models. Only return unique model ids unique_models = _deduplicate_litellm_router_models(models=all_models) diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.py index ae62bf5a67c..e1f0347a7cb 100644 --- a/litellm/proxy/utils.py +++ b/litellm/proxy/utils.py @@ -6459,7 +6459,7 @@ async def _apply_user_models_filter( model_access_groups: dict[str, list[str]], prisma_client: Optional["PrismaClient"], proxy_logging_obj: Optional["ProxyLogging"], - user_api_key_cache: Optional["DualCache"], + user_api_key_cache: Optional["UserApiKeyCache"], user_models_override: list[str] | None = None, ) -> list[str]: """ @@ -6554,7 +6554,7 @@ async def apply_user_models_filter_to_deployments( llm_router: Optional["Router"], prisma_client: Optional["PrismaClient"], proxy_logging_obj: Optional["ProxyLogging"], - user_api_key_cache: Optional["DualCache"], + user_api_key_cache: Optional["UserApiKeyCache"], user_models_override: list[str] | None = None, ) -> list[dict[str, Any]]: """