mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
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.
This commit is contained in:
parent
f39ee4aa22
commit
eee62875ae
1 changed files with 8 additions and 1 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue