Skip to content

refactor(typing): clear 1146 basedpyright Any errors across 365 files - #52768

Merged
mateo-berri merged 32 commits into
mainfrom
beluga_decrease_anys_20261117
Nov 21, 2026
Merged

mateo-berri merged 32 commits into
mainfrom
beluga_decrease_anys_20261117

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

This clears 1,118 loosely typed spots across 429 files so the type checker can catch real bugs there. Requests, responses, errors and spend tracking behave the same as on main

Details

Link to Devin session: https://app.devin.ai/sessions/3242d590986444e499b3a5b6958207b4
Open in Devin Desktop: https://app.devin.ai/desktop/session/3242d590986444e499b3a5b6958207b4?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

  • Main has 2,250 Any errors that let wrong values pass unchecked
  • The type checker cannot catch bugs hidden behind them

How it solves it:

  • Replaces Any with real types across 429 files
  • Narrows untyped values with the builtin they already called
  • Changes no request, response, error or spend behavior

User Flow

Before: the flow succeeds, and every request and its spend tracking behave as they do today

  1. A developer with a virtual key sends POST https://litellm-domain/v1/chat/completions with {"model": "gpt-4o", "messages": [{"role": "user", "content": "hi"}]}
  2. They get 200 OK with a chat.completion whose id looks like chatcmpl-... and token counts in usage
  3. GET https://litellm-domain/key/info?key=sk-... shows the key's spend went up by that request's cost

After: the same flow succeeds the same way, with nothing the user can see changed

  1. A developer with a virtual key sends POST https://litellm-domain/v1/chat/completions with {"model": "gpt-4o", "messages": [{"role": "user", "content": "hi"}]}
  2. They get 200 OK with a chat.completion whose id looks like chatcmpl-... and token counts in usage
  3. GET https://litellm-domain/key/info?key=sk-... shows the key's spend went up by that request's cost

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

Rule main this PR
reportAny 1797 920
reportExplicitAny 453 212
basedpyright total 92794 90559

Measured on the whole tree at 4e3875d against main at 5669abf with the type gate's own basedpyright run (litellm/scripts/type_check_gate.py). 7ad9fab after it only edits one test file, 21a528c only merges main, and c8526e8 marks three TypedDict fields ReadOnly, a typing-only change. make check passes at c8526e8

Tests. The new core_helpers tests compare each typed wrapper's result and error with the builtin it wraps, for ints, floats, strings, mappings, a UserString and an object whose __getattr__ answers every name. tests/unit/litellm_core_utils/test_core_helpers.py passes at c8526e8 (274 tests), and the suites are left to CI. 7ad9fab swaps operator.call, which needs Python 3.11, for a local helper so the file still collects on Python 3.10

Merge with main. 21a528c merges main at 0cfb2c3. Across the merges five files conflicted. The budget reset job and the budget endpoints take main's new typed raw-query code, the Cisco guardrail keeps both import lines and main's request_data type, the key endpoints keep both import lines, and the table repositories take main's file with prisma_client typed object

Recursion check. Six narrowing helpers called themselves after the builtin call that raises, so an attribute that answers only every other lookup recursed until RecursionError. They now raise the builtin's exception type instead, and a new test covers that case. The old require_attributes at e44098a raises RecursionError after 1,992 lookups on that object

CI. At 7ad9fab the required smoke passed, cost-map-guard, spend-logs-guard and zizmor were green, while lint passed and unit passed were red only through four failures main had too. Those are fixed on main by #53237, #53287, #53289 and #53295, and 21a528c merges them in. The six helpers this PR had tripped the recursion detector with are fixed in 4e3875d

Live A/B (/live-pr-risk). Two real proxies, base at 17fb98f and head at 53655d0, ran the same 50 scenarios in the same order. Each had 2 workers, its own Postgres, one Redis for router state and coordination_redis, and a mitm recorder in front of the real upstreams. Upstreams were OpenAI, Anthropic, Gemini, Vertex AI, xAI, Cohere, Langfuse, AWS Bedrock chat and guardrails, Azure AI Foundry and a local MCP server (A/B files). Head ran 53655d0's tree before one return in litellm/utils.py moved into an else block for ruff.

Last updated: c8526e8. QA ran on 53655d0. Changes since QA: that ruff-only move, five merges of main, 4e3875d (the six helpers raise where they used to call themselves, a line no builtin lets them reach) 7ad9fab (one test file) and c8526e8 (three TypedDict fields marked ReadOnly, which no runtime code reads). Proof remains valid because this PR's own diff against main changed only in the helpers' fall-through lines, which no request reaches, and in tests. Verification: the tip check below and the core_helpers tests

Observable base head Differs
Scenarios 50 50 upstream, timing
Client exchanges 170 170 upstream, timing
Provider requests 127 127 per-run inputs
Spend rows 123 122 rerun, race on main

Every request litellm sent upstream matched base after scrubbing ids and timestamps, with the same host, path, status and body the same number of times. The only body differences are values the run made itself, the MP3 the speech step returned and then uploaded for transcription, and the signed JWT in the Vertex AI token exchange. Bedrock and Azure chat, streaming, Responses and embeddings returned the same results, and both Bedrock guardrail modes blocked the same prompts and replies with the same 400

Every differing result traces to per-run values, the upstream or timing. Key suffixes in error text differ per run, Gemini answered two byte-identical requests differently, one team spend read ran before the batch write landed, and call types reached the spend log in a different order. Base has one more Azure chat row because its recorder missed a streaming call, which was run again to record its body. Container create and retrieve share one request id, so they race for one spend row. Base kept retrieve and head kept create here, and two earlier runs today kept the same one on both sides, so that race is on main

Commands
git worktree add --detach base 17fb98f7b43
git worktree add --detach head 53655d0867a
# per side: own Postgres, one Redis, and mitmdump -s wire_addon.py in front of the real upstreams
# env: OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, XAI_API_KEY, COHERE_API_KEY, LANGFUSE_*, AWS_*, AZURE_FOUNDRY_*
HTTPS_PROXY=http://127.0.0.1:$MITM DATABASE_URL=postgresql://...:$PG/litellm REDIS_PORT=$RP \
  PYTHONPATH=$WT $WT/.venv/bin/python litellm/proxy/proxy_cli.py --config config.yaml \
  --port $PORT --num_workers 2 --use_prisma_db_push
python scenario.py http://127.0.0.1:$PORT $MASTER_KEY out-$side $side
python diff_ab.py out-base out-head wire-base.jsonl wire-head.jsonl
python diff_bodies.py wire-base.jsonl wire-head.jsonl
bash spend_compare.sh

Tip check. Two real proxies, base at 5669abf (the merge base) and head at 4e3875d, each with 2 workers and its own Postgres, ran the User Flow and nine neighbours against OpenAI and Anthropic. Every case answered the same on both sides. The streamed reply had 5 or 6 data: lines on either side across reruns, since the model answered Ok or Ok.

Case base head
Chat completion with a virtual key 200, chat.completion, usage same
Streamed chat with usage 5 or 6 lines, 1 usage chunk, [DONE] same
/v1/messages on Claude message, usage same
Embeddings on a chat model 403 permission_error same
Model the key cannot use 403 key_model_access_denied same
max_tokens: -1 400 invalid_request_error same
/key/update budget and tpm 7.0, 1000 same
/team/new alias, budget, models same
/key/info spend above 0, budget 7.0, metadata kept same
/spend/logs rows 7 rows, same call types and statuses same
Tip check commands and output
# per side, from that side's worktree, with its own database
DATABASE_URL=postgresql://...:5432/qa52768_$side QA_MASTER_KEY=$MASTER_KEY PYTHONPATH=$WT \
  $WT/.venv/bin/python litellm/proxy/proxy_cli.py --config config.yaml --port $PORT --num_workers 2 --use_prisma_db_push

Head at 4e3875d

virtual key minted: sk-P0l...
$ curl -s -o /dev/null -w '%{http_code}' -X POST http://127.0.0.1:32861/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}'
200
$ curl -s -X POST http://127.0.0.1:32861/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['object'],d['choices'][0]['message']['content'],sorted(d['usage'].keys())[:3],d['usage']['prompt_tokens'])"
chat.completion Ok ['completion_tokens', 'completion_tokens_details', 'prompt_tokens'] 13

$ curl -s -N -X POST http://127.0.0.1:32861/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}' | grep -c '^data: '
5

$ curl -s -X POST http://127.0.0.1:32861/v1/messages -H "x-api-key: $KEY" -H 'anthropic-version: 2023-06-01' -H 'Content-Type: application/json' -d '{"model":"claude-haiku","max_tokens":8,"messages":[{"role":"user","content":"Reply with the single word ok"}]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['type'],d['role'],d['content'][0]['type'],d['usage']['input_tokens'])"
message assistant text 13

$ curl -s -X POST http://127.0.0.1:32861/v1/embeddings -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","input":"hi"}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
403 permission_error

$ curl -s -X POST http://127.0.0.1:32861/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"not-a-model","messages":[{"role":"user","content":"hi"}]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
403 key_model_access_denied

$ curl -s -X POST http://127.0.0.1:32861/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}],"max_tokens":-1}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
400 invalid_request_error

$ curl -s -X POST http://127.0.0.1:32861/key/update -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' -d "{\"key\":\"$KEY\",\"max_budget\":7,\"tpm_limit\":1000}" | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['max_budget'],d['tpm_limit'],d['models'])"
7.0 1000 ['gpt-4o-mini', 'claude-haiku']

$ curl -s -X POST http://127.0.0.1:32861/team/new -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' -d '{"team_alias":"qa52768","max_budget":10,"models":["gpt-4o-mini"]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['team_alias'],d['max_budget'],d['models'])"
qa52768 10.0 ['gpt-4o-mini']

$ curl -s "http://127.0.0.1:32861/key/info?key=$KEY" -H "Authorization: Bearer $MASTER_KEY" | python3 -c "import sys,json;d=json.load(sys.stdin)['info'];print('spend>0:',d['spend']>0,'max_budget:',d['max_budget'],'metadata:',d['metadata'])"
spend>0: True max_budget: 7.0 metadata: {'qa': '52768'}

$ curl -s "http://127.0.0.1:32861/spend/logs?api_key=$KEY" -H "Authorization: Bearer $MASTER_KEY" | python3 -c "import sys,json;d=json.load(sys.stdin);print(sorted((r['call_type'],r['model'],r['status']) for r in d))"
[('acompletion', 'not-a-model', 'failure'), ('acompletion', 'openai/gpt-4o-mini', 'failure'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('aembedding', 'openai/gpt-4o-mini', 'failure'), ('anthropic_messages', 'anthropic/claude-haiku-4-5', 'success')]

Base at 5669abf

virtual key minted: sk-Anc...
$ curl -s -o /dev/null -w '%{http_code}' -X POST http://127.0.0.1:33441/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}'
200
$ curl -s -X POST http://127.0.0.1:33441/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['object'],d['choices'][0]['message']['content'],sorted(d['usage'].keys())[:3],d['usage']['prompt_tokens'])"
chat.completion Ok ['completion_tokens', 'completion_tokens_details', 'prompt_tokens'] 13

$ curl -s -N -X POST http://127.0.0.1:33441/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"Reply with the single word ok"}],"max_tokens":5,"temperature":0}' | grep -c '^data: '
6

$ curl -s -X POST http://127.0.0.1:33441/v1/messages -H "x-api-key: $KEY" -H 'anthropic-version: 2023-06-01' -H 'Content-Type: application/json' -d '{"model":"claude-haiku","max_tokens":8,"messages":[{"role":"user","content":"Reply with the single word ok"}]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['type'],d['role'],d['content'][0]['type'],d['usage']['input_tokens'])"
message assistant text 13

$ curl -s -X POST http://127.0.0.1:33441/v1/embeddings -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","input":"hi"}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
403 permission_error

$ curl -s -X POST http://127.0.0.1:33441/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"not-a-model","messages":[{"role":"user","content":"hi"}]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
403 key_model_access_denied

$ curl -s -X POST http://127.0.0.1:33441/v1/chat/completions -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"hi"}],"max_tokens":-1}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['error']['code'], d['error']['type'])"
400 invalid_request_error

$ curl -s -X POST http://127.0.0.1:33441/key/update -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' -d "{\"key\":\"$KEY\",\"max_budget\":7,\"tpm_limit\":1000}" | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['max_budget'],d['tpm_limit'],d['models'])"
7.0 1000 ['gpt-4o-mini', 'claude-haiku']

$ curl -s -X POST http://127.0.0.1:33441/team/new -H "Authorization: Bearer $MASTER_KEY" -H 'Content-Type: application/json' -d '{"team_alias":"qa52768","max_budget":10,"models":["gpt-4o-mini"]}' | python3 -c "import sys,json;d=json.load(sys.stdin);print(d['team_alias'],d['max_budget'],d['models'])"
qa52768 10.0 ['gpt-4o-mini']

$ curl -s "http://127.0.0.1:33441/key/info?key=$KEY" -H "Authorization: Bearer $MASTER_KEY" | python3 -c "import sys,json;d=json.load(sys.stdin)['info'];print('spend>0:',d['spend']>0,'max_budget:',d['max_budget'],'metadata:',d['metadata'])"
spend>0: True max_budget: 7.0 metadata: {'qa': '52768'}

$ curl -s "http://127.0.0.1:33441/spend/logs?api_key=$KEY" -H "Authorization: Bearer $MASTER_KEY" | python3 -c "import sys,json;d=json.load(sys.stdin);print(sorted((r['call_type'],r['model'],r['status']) for r in d))"
[('acompletion', 'not-a-model', 'failure'), ('acompletion', 'openai/gpt-4o-mini', 'failure'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('acompletion', 'openai/gpt-4o-mini', 'success'), ('aembedding', 'openai/gpt-4o-mini', 'failure'), ('anthropic_messages', 'anthropic/claude-haiku-4-5', 'success')]
Risk report

Breaking. None observed. No scenario answered differently on head except where the upstream itself answered differently to the same request

Backward incompatible. None known. Errors come from the same builtins main calls, with the same types and messages, and the client SDK keeps main's return types

Regression risk. Changed code this run could not reach live: SageMaker, the S3 cache and vector stores, guardrails other than Bedrock and the content filter, integrations other than Langfuse and OTel, and the long-tail providers. CI's unit suites are their only coverage

Area Status
Proxy endpoints and management verified live
Core utils, caching, router verified live
Eight providers above verified live
MCP server verified live
Langfuse, OTel, dotprompt verified live
Bedrock guardrail verified live
Other integrations CI only
Other guardrails CI only
Other providers CI only

Type

🧹 Refactoring

Caveats (if any)

Low

  • Untyped JSON passes a no-op TypeAdapter(object), about 0.7µs per call
  • Some choice and usage rows get one extra pydantic validation
  • Providers and plugins without live credentials rely on CI only
  • test_spend_counter_batch_ledger.py reports Redis calls out of order about 1 run in 48, on main too
  • Bugbot did not review, since it is paused for an unpaid invoice

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

Note

Low Risk
Refactor is annotation and validation-wrapping only; live A/B and tip checks reported identical API behavior, with main risk being a missed edge case in new narrowing helpers rather than intentional logic changes.

Overview
This is a codebase-wide static typing cleanup aimed at clearing ~1,100+ basedpyright Any violations across hundreds of files, without changing intended runtime behavior.

The main mechanical changes are: replacing loose Any annotations with object, Mapping[str, object], Protocols, and TypedDicts; routing untyped JSON and lazy-loaded attributes through pydantic.TypeAdapter(object) validation at boundaries (caching, A2A, containers, streaming bridges, etc.); and narrowing dynamic values via shared helpers (require_attributes, subscript, as_object_list, json_contains, float_of, and similar) instead of unchecked dict access. Touches span A2A/bedrock bridges, batch/cache layers, responses↔chat transformation, containers, harness/deepagents, integrations (Slack, ClickHouse, prompts), and proxy enterprise endpoints. litellm/__init__.py also tightens a few module globals (audit_log_callbacks, secret_manager_client) and adds global_prompt_directory.

Custom logger hook signatures now use object / AsyncGenerator[object, None] instead of Any/ModelResponseStream, which is typing-only for callers.

Reviewed by Cursor Bugbot for commit c8526e8. Bugbot is set up for automated code reviews on this repo. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@veria-ai

veria-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The latest changes appear safe to merge and fully address the previous finding.

Summary

This PR replaces loose types across the SDK, provider adapters, proxy, caching, and logging code. It adds shared typed helpers and tests that compare their behavior with Python builtins.

The latest changes wrap three previously updated fields in ReadOnly[...]. They address the previous finding without changing request or response behavior. No new actionable issues were found in these changes. Tests were not run during this review.

  • Core helpers describe loosely typed values without changing the operations they use.

Reviews (6) · Last reviewed commit: "refactor(typing): mark the three widened..." · Reviewed by Greptile

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri mateo-berri added the run-all-unit-shards Run the full unit test matrix instead of only the core shards label Nov 19, 2026
The Anthropic chat transform now rejects a decoded body that is not a JSON
object. Four tests mocked the HTTP client with a bare MagicMock, whose json()
is never a real decoded response, so they now return a real Anthropic message.
The wave 14 pass dropped the now-unused FileTypes import, which also removed the litellm.utils.FileTypes attribute SDK users could import. Re-export it as a TypeAlias the same way TextChoices is.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…20261117

# Conflicts:
#	litellm/litellm_core_utils/llm_response_utils/response_metadata.py
#	litellm/llms/bedrock/claude_platform/messages_transformation.py
#	litellm/llms/gemini/files/transformation.py
#	litellm/llms/vertex_ai/gemini_embeddings/batch_embed_content_handler.py
#	litellm/proxy/db/budget_window_spend_writer.py
#	litellm/proxy/mcp_server/operations.py
#	litellm/proxy/pass_through_endpoints/success_handler.py
#	litellm/responses/litellm_completion_transformation/transformation.py
#	litellm/responses/streaming_iterator.py
…20261117

# Conflicts:
#	litellm/proxy/db/check_migration.py
…20261117

# Conflicts:
#	litellm/llms/anthropic/chat/handler.py
#	litellm/llms/openai/responses/transformation.py
#	litellm/proxy/auth/host/python.py
#	litellm/proxy/common_utils/reset_budget_job.py
#	litellm/proxy/guardrails/guardrail_hooks/bedrock_guardrails.py
#	litellm/repositories/table_repositories.py
#	litellm/responses/streaming_iterator.py
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

…3.10

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor

cursor Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Bugbot is paused — your team has an unpaid invoice

Bugbot is paused because your team has an unpaid invoice.

Pay it from the billing page in the Cursor dashboard and Bugbot resumes automatically.

(requestId: 02e70ae9-5462-4e77-8251-f09aee824eb2)

@mateo-berri
mateo-berri enabled auto-merge (squash) November 21, 2026 02:50
mateo-berri and others added 2 commits November 21, 2026 03:31
…20261117

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…20261117

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread litellm/types/llms/anthropic.py Resolved
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri
mateo-berri merged commit 5084cef into main Nov 21, 2026
107 of 108 checks passed
@mateo-berri
mateo-berri deleted the beluga_decrease_anys_20261117 branch November 21, 2026 04:25
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c8526e8. Configure here.

list: A list of completion results.
"""
args: Final = locals()
args: Final = MappingProxyType[str, object](locals())

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.

batch_completion crashes on MappingProxyType subscript

High Severity

batch_completion now builds args with MappingProxyType[str, object](locals()). types.MappingProxyType is not a PEP 585 generic, so that subscript raises TypeError at runtime on supported Python 3.10–3.13 before any completions run.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c8526e8. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not a bug: types.MappingProxyType has been subscriptable since Python 3.9, and this exact line returns the mapping on 3.10.12 and 3.12.16 when run

shudonglin pushed a commit to rayward-external/litellm that referenced this pull request Nov 21, 2026
Upstream's BerriAI#52768 typing-cleanup refactor collapsed the typing import
line in two fork-diverged files, dropping Any while it stayed in live
use: google_genai/adapters/transformation.py's _is_terminal_sse_chunk
and success_handler.py's _coerce_token_count/extract_generic_usage.
Caught by the lint job's ruff F821 sweep.
yujonglee-berri added a commit that referenced this pull request Nov 21, 2026
#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 added a commit that referenced this pull request Nov 21, 2026
…#53430)

#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.
yuneng-berri added a commit that referenced this pull request Nov 21, 2026
…ops failing on main (#53436)

#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-all-unit-shards Run the full unit test matrix instead of only the core shards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants