Skip to content

fix(responses): type the cold storage helpers with Mapping so ruff passes on main - #53436

Merged
yuneng-berri merged 1 commit into
mainfrom
litellm_/resolve-merge-conflicts-27ca45
Nov 21, 2026
Merged

yuneng-berri merged 1 commit into
mainfrom
litellm_/resolve-merge-conflicts-27ca45

Conversation

@yuneng-berri

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • ruff check fails on main with F821 SpendLogsPayload
  • Every PR that merges main now fails the lint job

How it solves it:

User Flow

Before: a contributor's PR fails lint on code they never touched

  1. They merge main into their branch and push
  2. The lint / python job fails at "Run Ruff linting" with two F821 errors in session_handler.py
  3. "lint passed" goes red and the PR is blocked

After: the same push gets past "Run Ruff linting"

  1. They merge main into their branch and push
  2. "Run Ruff linting" passes and the later lint steps run again

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 f6d00ec.

Scope is two type annotations in litellm/responses/litellm_completion_transformation/session_handler.py. Rationale is that the diff is mechanical and changes no runtime behavior. Both helpers only ever receive Mapping[str, object] spend logs from their one caller, which is what every other helper in the module already takes after #52768. A lint run is the complete proof here.

Ruff at main (03fd3d7), run from litellm/ the way CI does

$ ruff check .
F821 Undefined name `SpendLogsPayload`
   --> responses/litellm_completion_transformation/session_handler.py:445:44
F821 Undefined name `SpendLogsPayload`
   --> responses/litellm_completion_transformation/session_handler.py:452:17
Found 2 errors.

Checks at f6d00ec

$ (cd litellm && ruff check .)
All checks passed!
$ ruff check --config .github/linters/ruff-tests.toml tests
All checks passed!
$ ruff format --check litellm/responses/litellm_completion_transformation/session_handler.py
1 file already formatted
$ python litellm/scripts/ruff_strict_gate.py --base 03fd3d71fe2
OK: no strict rule grew past its merge-base count
$ python litellm/scripts/type_discipline_gate.py --base 03fd3d71fe2
OK: no LIT rule grew past its merge-base count
$ python litellm/scripts/type_check_gate.py --base 03fd3d71fe2
OK: every basedpyright rule is within its ceiling
$ pytest tests/unit/responses/litellm_completion_transformation/test_session_handler.py \
    tests/unit/responses/litellm_completion_transformation/test_session_handler_with_cold_storage.py -q
84 passed

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

…ops failing on main

#50768 merged code that names SpendLogsPayload after #52768 removed that
import, so ruff check reports F821 on main and fails the lint job on every
PR that merges main. Use Mapping[str, object] like the rest of the module.
@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

@yuneng-berri
yuneng-berri enabled auto-merge (squash) November 21, 2026 21:44
@yuneng-berri
yuneng-berri merged commit 1fa7e4a into main Nov 21, 2026
46 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_/resolve-merge-conflicts-27ca45 branch November 21, 2026 21:45
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.

2 participants