Repository navigation
refactor(types): replace Unknown with proven types in 390 files - #53715
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
[Low impact] The PR appears safe to merge, with no actionable new issue established.
|
|
bugbot run |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…it on Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
The file is code-owned and moves to its own PR Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…_20261122_s3 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
bugbot run |
…eam lookups into a helper Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…_20261122_s3 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
…ansform Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
…_20261122_s3 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # tests/unit/integrations/otel/test_otel_v2_logger.py
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit da97786. Configure here.
Handwritten 1-3 sentence description
Adds type annotations to 390 backend files so that function parameters with no type, and the values derived from them, are checked by the type checker instead of silently skipped. Nothing changes at runtime, this is one part of a series that brings the six Unknown type rules to zero
Details
Link to Devin session: https://app.devin.ai/sessions/dab84fb5bad94d44ac97ef8e00365548
Open in Devin Desktop: https://app.devin.ai/desktop/session/dab84fb5bad94d44ac97ef8e00365548?variant=devin
Requested by: @mateo-berri
TLDR
Problem this solves:
Anybut is not counted byreportAnyreportMissingParameterType,reportUnknownParameterType,reportUnknownMemberType,reportUnknownVariableType,reportUnknownArgumentType,reportUnknownLambdaType)reportAnyto zero would still leave these signatures untypedHow it solves it:
User Flow
This change is types-only, so the developer-facing flow is identical before and after
Before
A developer runs the proxy from the merge base and every route answers as listed
POST /v1/chat/completionson the Gemini model returns 200 with contentPONGand usagePOST /v1/chat/completionswithstream: trueon the OpenAI model returns 200 with a final usage chunkPOST /v1/embeddingsreturns 200 with one 3072-dim vectorPOST /key/generatereturns a virtual key scoped to one modelPOST /key/deletereturns 200 and the deleted key is then refused with 401GET /guardrails/listreturns 200GET /v1/modelsreturns 200 with the four configured modelsPOST /v1/responsesreturns 200, streaming and not, on Gemini and OpenAIAfter
A developer runs the proxy from this PR's tip and every route answers the same way
POST /v1/chat/completionson the Gemini model returns 200 with contentPONGand usagePOST /v1/chat/completionswithstream: trueon the OpenAI model returns 200 with a final usage chunkPOST /v1/embeddingsreturns 200 with one 3072-dim vectorPOST /key/generatereturns a virtual key scoped to one modelPOST /key/deletereturns 200 and the deleted key is then refused with 401GET /guardrails/listreturns 200GET /v1/modelsreturns 200 with the four configured modelsPOST /v1/responsesreturns 200, streaming and not, on Gemini and OpenAIPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
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 moreScreenshots / Proof of Fix
Last updated: b016138. QA ran on 4196329. Changes since QA: merges of main, plus annotations removed from 8 files so their signatures match main again. Proof remains valid because the only change to this PR's own diff since then is annotations taken back out, which the interpreter never evaluates differently, and no statement, default or call changed. Verification:
make checkpasses at b016138 and the CI unit suites pass there, exceptintegrations, which fails the same way on main at 203569c (the Prisma call site count test, after #53599)Shared setup for both runs. Same config, same payloads, same live providers, same Postgres; only the checked-out commit differs
Before (3e7961b)
Type-check count
Run basedpyright over the tree the way
scripts/type_check_gate.pydoes:Observed:
Chat completions
Send a non-streaming chat completion to
qa-gemini:Observed:
Send a streaming chat completion with usage to
qa-openai:Observed:
Send a non-streaming chat completion to
qa-fireworks:Observed:
Tool calling
Send a chat completion to
qa-geminicarrying aget_weatherfunction tool:Observed:
Responses API
Send a non-streaming responses request to
qa-gemini:Observed:
Send a non-streaming responses request to
qa-openai:Observed:
Send a streaming responses request to
qa-gemini:Observed:
Embeddings
Send an embedding request to
qa-embed:Observed:
Virtual key lifecycle, model access control and spend
Generate a key scoped to
qa-gemini, use it on both models, read its spend, delete it and reuse it:Observed:
Guardrails and model list
List the guardrails and the models:
Observed:
After (4196329)
Type-check count
Run basedpyright over the tree the way
scripts/type_check_gate.pydoes:Observed:
Chat completions
Send a non-streaming chat completion to
qa-gemini:Observed:
Send a streaming chat completion with usage to
qa-openai:Observed:
Send a non-streaming chat completion to
qa-fireworks:Observed:
Tool calling
Send a chat completion to
qa-geminicarrying aget_weatherfunction tool:Observed:
Responses API
Send a non-streaming responses request to
qa-gemini:Observed:
Send a non-streaming responses request to
qa-openai:Observed:
Send a streaming responses request to
qa-gemini:Observed:
Embeddings
Send an embedding request to
qa-embed:Observed:
Virtual key lifecycle, model access control and spend
Generate a key scoped to
qa-gemini, use it on both models, read its spend, delete it and reuse it:Observed:
Guardrails and model list
List the guardrails and the models:
Observed:
Type
🧹 Refactoring
Caveats (if any)
Low
Final Attestation
Note
Low Risk
Annotation- and helper-only refactors with stated QA parity; no auth, billing, or data-path logic changes beyond equivalent typing guards.
Overview
This PR extends static typing across hundreds of backend modules—core utils, caching, A2A/Watsonx/Bedrock paths, Anthropic messages, integrations (Arize, Galileo, Bitbucket, Opik, CloudZero, etc.), and LLM provider transforms—so parameters, returns, locals, and
**kwargsuse concrete types (Mapping[str, object], typeddict/list,Coroutine[...],Protocols,TypeVars) instead of baredict/list/Unknown.A few spots go beyond pure annotations while keeping the same behavior: OTel service logging types dedupe sets as
set[int]; Pydantic AI A2A streaming exposestimeout/chunk_size/delay_msas keyword-only defaults instead of reading them from**kwargs; Galileo and Watsonx Orchestrate use smallas_object_list/_as_dicthelpers for safer JSON-shaped data; Bitbucket centralizes HTTP error status extraction; anthropic beta headers use aMutableMappingTypeVarso filtered headers stay correctly typed.No intended runtime or API contract changes—this is for basedpyright coverage (per PR notes, thousands fewer Unknown-type errors).
Reviewed by Cursor Bugbot for commit da97786. Bugbot is set up for automated code reviews on this repo. Configure here.