Skip to content

fix(responses): type the cold storage helpers' spend log as a mapping - #53430

Merged
yujonglee-berri merged 1 commit into
mainfrom
litellm_fix_session_handler_spend_logs_import
Nov 21, 2026
Merged

yujonglee-berri merged 1 commit into
mainfrom
litellm_fix_session_handler_spend_logs_import

Conversation

@yujonglee-berri

@yujonglee-berri yujonglee-berri commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • Ruff fails with F821 on main and every open PR
  • Two annotations name SpendLogsPayload without importing it

How it solves it:

  • Annotate both helpers with Mapping[str, object], which is what the caller passes
  • Importing SpendLogsPayload instead adds a basedpyright reportArgumentType at the call site

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

E2E exception at e47d756. The change only edits two type annotations, so nothing changes at runtime. #50768 added two helpers annotated with "SpendLogsPayload" after #52768 had removed that import, and both merged cleanly on their own. The helpers only call .get() on the spend log and their one caller passes a Mapping[str, object], so they take that type. No test is added since ruff F821 and the basedpyright gate in CI already catch this exact defect.

At main (03fd3d7), cd litellm && uv run --no-sync ruff check . reports F821 Undefined name SpendLogsPayload at session_handler.py:445 and :452, Found 2 errors. At e47d756 the same command prints All checks passed!. Running .venv-typecheck/bin/basedpyright on the file shows one fewer reportArgumentType and one fewer reportUnknownMemberType than main, and no rule grows.

Type

🐛 Bug Fix

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@veria-ai

veria-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

#50768 annotated two cold storage helpers with "SpendLogsPayload" after #52768
had dropped that import, so ruff fails with F821 on main and on every PR. The
helpers only read the spend log with .get() and their caller passes a
Mapping[str, object], so they take that type instead of the TypedDict.
@yujonglee-berri
yujonglee-berri force-pushed the litellm_fix_session_handler_spend_logs_import branch from 8a3df27 to e47d756 Compare November 21, 2026 21:39
@yujonglee-berri yujonglee-berri changed the title fix(responses): import SpendLogsPayload for the session handler annotations fix(responses): type the cold storage helpers' spend log as a mapping Nov 21, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@yujonglee-berri
yujonglee-berri enabled auto-merge (squash) November 21, 2026 21:41
@yujonglee-berri
yujonglee-berri merged commit b0c0d63 into main Nov 21, 2026
46 of 47 checks passed
@yujonglee-berri
yujonglee-berri deleted the litellm_fix_session_handler_spend_logs_import branch November 21, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant