fix(proxy): use contextlib.suppress for cost-map lookup miss to stay under BLE001 budget
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
ryan 2026-09-21 21:30:04 +00:00
parent 099a8f66eb
commit f8c28e2f5a

View file

@ -14,7 +14,7 @@ import asyncio
import datetime
import json
from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping, Sequence
from contextlib import AbstractAsyncContextManager, asynccontextmanager
from contextlib import AbstractAsyncContextManager, asynccontextmanager, suppress
from dataclasses import dataclass
from fnmatch import fnmatchcase
from json import JSONDecodeError
@ -940,10 +940,9 @@ def _cost_map_entry(db_model: Deployment, incoming_model_info: Mapping[str, obje
lookup: Final = base_model if isinstance(base_model, str) else _decrypted_model(db_model.litellm_params.model)
if lookup is None:
return MappingProxyType({})
try:
with suppress(Exception):
return MappingProxyType(dict(litellm.get_model_info(model=lookup)))
except Exception:
return MappingProxyType({})
return MappingProxyType({})
LoadedCatalog: TypeAlias = Callable[[], Mapping[str, Mapping[str, object]]] # mutable-ok: Callable parameter syntax