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:
Srivatsa03 2026-10-11 22:48:36 -05:00
parent 4eeb70009a
commit f949f1735b

View file

@ -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(