mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-30 06:43:27 +00:00
fix(proxy): read total_tokens with .get default, not an in-check ternary
The membership-guarded index tripped SIM401 (prefer dict.get), but a plain .get on the SpendLogsPayload TypedDict trips basedpyright's unknown-member rule. Use .get with a 0 default (tolerant and SIM401-clean) and suppress just the one overload-unknown diagnostic with a reason.
This commit is contained in:
parent
4eeb70009a
commit
f949f1735b
1 changed files with 4 additions and 1 deletions
|
|
@ -1060,13 +1060,16 @@ class DBSpendUpdateWriter:
|
|||
traceback.format_exc(),
|
||||
)
|
||||
|
||||
team_tokens: Final = payload.get( # pyright: ignore[reportUnknownMemberType] # SpendLogsPayload.get overload is partially unknown; total_tokens is a required int
|
||||
"total_tokens", 0
|
||||
)
|
||||
try:
|
||||
await self._update_team_db(
|
||||
response_cost=response_cost,
|
||||
team_id=team_id,
|
||||
user_id=user_id,
|
||||
prisma_client=prisma_client,
|
||||
tokens=payload["total_tokens"] if "total_tokens" in payload else 0,
|
||||
tokens=team_tokens,
|
||||
)
|
||||
except Exception:
|
||||
verbose_proxy_logger.debug(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue