fix(typing): bring reportReturnType back under the basedpyright budget - #31101
Closed
mateo-berri wants to merge 1 commit into
Closed
fix(typing): bring reportReturnType back under the basedpyright budget#31101mateo-berri wants to merge 1 commit into
mateo-berri wants to merge 1 commit into
Conversation
completion()'s async/batch dispatch paths return a coroutine (MCP, responses bridge), a list (batch_completion_models), or the untyped fallback runner's result, none of which match its declared Union[ModelResponse, CustomStreamWrapper]. The #30813 dispatch refactor made basedpyright able to analyze these paths and surfaced four reportReturnType errors, pushing the codebase total to 143 against the committed ceiling of 139. Suppress exactly those four sites with coded, reasoned pyright ignores (the repo sets enableTypeIgnoreComments=false, so the pre-existing type: ignore[return-value] on the MCP path was dead). Widening completion()'s return type would ripple across thousands of call sites and is out of scope.
Contributor
Author
|
Closing in favor of #31103, which carries the same commit on a Generated by Claude Code |
Contributor
Author
|
Folding this into #30446 instead of shipping it as a standalone PR, since that branch is the one currently blocked by the red lint gate and the fix is a single commit that belongs alongside it. The same commit (the four Generated by Claude Code |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
The LiteLLM Linting check is red on every PR currently branched off
litellm_internal_staging(for example #30446), failing the basedpyright budget gate:This is a staging-level regression, not a problem with any individual PR: the gate (
scripts/type_check_gate.py) counts absolute codebase-wide errors against the committed ceiling, so a branch off the current staging tip inherits the red regardless of what it changes.Root cause
The budget was last ratcheted at
1bd603d1to baseline 126 (cap 126 + slack 13 = 139). Blaming each of the 143 currentreportReturnTypeoffenders, exactly four were introduced after that ratchet, all by #30813 ("refactor(completion): extract provider dispatch into typed helpers"):litellm/main.pyMCP dispatch path (acompletion_with_mcp)completion_with_fallbacks)batch_completion_models)responses_api_bridge.completion)That refactor made basedpyright able to analyze
completion()for the first time and correctly addedpyright: ignore[reportReturnType]to the 61 extracted helpers, but it missed these four returns that live incompletion()'s own body. They take the codebase total from 139 to 143, four over the ceiling.Fix
Suppress exactly those four sites with coded, reasoned pyright ignores. Each path returns a coroutine (MCP, responses bridge), a list (batch), or the untyped fallback runner's result, none of which match
completion()'s declaredUnion[ModelResponse, CustomStreamWrapper]; the async/batch callers handle those shapes. Wideningcompletion()'s return type would ripple across thousands of call sites and is out of scope. Note the repo setsenableTypeIgnoreComments=false, so the pre-existingtype: ignore[return-value]on the MCP path was dead and is replaced with a workingpyright: ignore.After the fix the codebase total is back to 139, exactly at the ceiling, and the gate passes.
Type
🐛 Bug Fix
Changes
Adds four
pyright: ignore[reportReturnType]suppressions, each with a reason, to the async/batch dispatch returns incompletion(); no behavior change.Generated by Claude Code