From eee62875ae852c43cdef4bd6b13ef74e513bbf14 Mon Sep 17 00:00:00 2001 From: RichardoMu <44485717+RichardoMrMu@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:00:55 +0800 Subject: [PATCH] fix(types): keep the token-limit predicate's mapping access fully typed The new `_deployment_token_limits_configured` reads two keys off a bare `Mapping`, so both `.get` member accesses are only partially known and reportUnknownMemberType lands two over its ceiling on the basedpyright delta gate. Pin the value type with a cast before reading the keys. Checked with basedpyright 1.40.2 on litellm/router.py: reportUnknownMemberType 1530 -> 1528, reportExplicitAny unchanged at 28. --- litellm/router.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/litellm/router.py b/litellm/router.py index 13f30c6e021..826f0491fe8 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -10775,7 +10775,14 @@ class Router: """ if not isinstance(model_info, Mapping): return False - return model_info.get("max_input_tokens") is not None and model_info.get("max_output_tokens") is not None + # ``Mapping`` is unparameterised here, so pin the key/value types before + # reading the keys: bare ``Mapping`` makes both ``.get`` member accesses + # only partially known, which trips the basedpyright delta gate. + typed_model_info: Final = cast(Mapping[str, object], model_info) # cast-ok: isinstance check above + return ( + typed_model_info.get("max_input_tokens") is not None + and typed_model_info.get("max_output_tokens") is not None + ) async def arefresh_model_info(self, *, client: AsyncHTTPHandler | None = None) -> None: """Refresh token limits advertised by configured OpenAI-compatible deployments."""