Repository navigation
chore(lint): bring ANN202 and BLE001 back under the strict-rule budget - #40444
Conversation
Annotate the return types of dispatch_async and transform_then_dispatch in llm_http_handler and _send_batch in azure_sentinel, and mark four legitimate broad catches with the repo's noqa convention, so the promote PR's lint job passes the strict gate again. Supersedes #40328.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR restores the strict lint gate to budget without changing runtime behavior
Confidence Score: 5/5The PR appears safe to merge because its annotations match runtime contracts and its suppressions follow the strict-lint convention No actionable failures remain; the changes affect static linting only, and the added import, return types, and suppression syntax are compatible with their surrounding contracts
|
| Filename | Overview |
|---|---|
| litellm/integrations/azure_sentinel/azure_sentinel.py | Adds an accurate httpx.Response return annotation to the batch callback |
| litellm/llms/custom_httpx/llm_http_handler.py | Adds return annotations matching the asynchronous dispatch helpers and their callers |
| litellm/litellm_core_utils/get_model_cost_map.py | Documents and suppresses the intentional broad catch in background retry handling |
| litellm/litellm_core_utils/llm_cost_calc/utils.py | Documents and suppresses the existing unmapped-model fallback catch |
| litellm/proxy/_experimental/mcp_server/server.py | Documents and suppresses the existing failure-hook isolation catch |
| litellm/proxy/management_endpoints/cost_tracking_settings.py | Documents and suppresses the existing unpriceable-model exception mapping |
Reviews (1): Last reviewed commit: "chore(lint): bring ANN202 and BLE001 bac..." | Re-trigger Greptile
Devin e2e QATested at: 8bb6d8c No-regression check for a lint-only change: the same real proxy boot and the same two real Anthropic calls ( Before (096984b)Boot a real proxy from this commit on a random free port
Non-streaming POST /v1/chat/completions (Anthropic, shared HTTP handler)
Streaming POST /v1/chat/completions (Anthropic, shared HTTP handler)
After (8bb6d8c)Boot a real proxy from this commit on a random free port
Non-streaming POST /v1/chat/completions (Anthropic, shared HTTP handler)
Streaming POST /v1/chat/completions (Anthropic, shared HTTP handler)
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
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 8bb6d8c. Configure here.
f529d6d
into
litellm_internal_staging
TLDR
Problem this solves:
except Exceptionblocks push BLE001 over its ceilingHow it solves it:
dispatch_async,transform_then_dispatch, and_send_batch# noqa: BLE001 # <reason>conventionUser Flow
Before: the engineer promoting staging to main sees the lint job fail on the promote PR and merges it red
litellm_internal_stagingtomainat main...litellm_internal_stagingFAIL: strict-rule totals exceed their limitnaming ANN202 over its ceilingAfter: the engineer promoting staging to main sees the lint job pass on the promote PR
litellm_internal_stagingtomainat main...litellm_internal_stagingOK: every strict rule is within its codebase ceilingRelevant issues
Supersedes #40328
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<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@greptileaito re-request a review after pushing changes)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
Both runs use the same commands from a bootstrapped worktree. The gate is the exact command the "LiteLLM Linting" job runs on a promote PR, with
origin/mainas the base, and the count comes from the strict config overlitellm/Before (096984b, merge base on
litellm_internal_staging)Strict gate against main
python scripts/ruff_strict_gate.py --base origin/mainANN202 on the three helpers
ruff check --config ruff-strict.toml --select ANN202 --output-format concise litellm/llms/custom_httpx/llm_http_handler.py litellm/integrations/azure_sentinel/azure_sentinel.pyStrict totals over litellm/
ruff check litellm --config ruff-strict.toml --output-format json --exit-zero | python3 -c "import json,sys,collections; c=collections.Counter(i['code'] for i in json.load(sys.stdin)); print('ANN202', c['ANN202'], 'BLE001', c['BLE001'])"ANN202 828 BLE001 2915(limits 829 and 2914)After (8bb6d8c, PR tip)
Strict gate against main
python scripts/ruff_strict_gate.py --base origin/main--base origin/litellm_internal_stagingprintsOKtooANN202 on the three helpers
ruff check --config ruff-strict.toml --select ANN202 --output-format concise litellm/llms/custom_httpx/llm_http_handler.py litellm/integrations/azure_sentinel/azure_sentinel.py_handle_errorat 5994 and_backend_connectionat 6551);_send_batch,dispatch_async, andtransform_then_dispatchare goneStrict totals over litellm/
ANN202 825 BLE001 2911(limits 829 and 2914)make checkat the tip:check: PASS(Python lint, LIT and TQ budgets, basedpyright budget, ruff format, dashboard API-type sync)Type
🧹 Refactoring
🚄 Infrastructure
Caveats (if any)
Medium
Low
# noqa: BLE001lines count as fresh debt for the daily tech-debt automation# noqain the last 24 hours, so the next rollinglitellm_techdebt_PR may try to remove them--base origin/mainpasses from a worktree at the tip and after a merge preview onto the current staging tip, and the next promote PR is the real check# noqa: BLE001lines can go stale without RUF100 noticingruff-strict.tomlselectsBLEbut also listsBLE001underexternal, so an unused BLE001 noqa is never flagged; pre-existing config issue, not changed hereOpen in Devin Desktop: https://app.devin.ai/desktop/session/1d398e0db179497bb299d81c219f756b?variant=devin
Requested by: @mateo-berri
Note
Low Risk
Lint and type-annotation only; broad exception handling is unchanged aside from documented noqa comments.
Overview
Brings the strict ruff gate back under budget so staging→main promote PRs pass LiteLLM Linting again. No intended runtime behavior change.
ANN202: Adds return types on three nested helpers—Azure Sentinel
_send_batch(httpx.Response, plushttpximport), and inllm_http_handlerdispatch_async(Coroutine[..., ModelResponse | CustomStreamWrapper]) andtransform_then_dispatch(ModelResponse | CustomStreamWrapper).BLE001: Documents four intentional broad
except Exceptionhandlers with# noqa: BLE001and short reasons: background model cost map retry, unmapped model inget_billed_token_rates, MCP proxy failure-hook logging, and cost-trackingcompletion_cost→ HTTP 404 mapping.Reviewed by Cursor Bugbot for commit 8bb6d8c. Bugbot is set up for automated code reviews on this repo. Configure here.