Repository navigation
Fix undefined kwargs in InFlightRequestsMiddleware - #22523
Merged
Merged
Conversation
kwargs dict was used but never initialized, causing F821 (undefined name) lint errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryFixes a
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/middleware/in_flight_requests_middleware.py | Initializes kwargs as an empty dict before the conditional block, fixing a NameError that would occur at runtime when _get_gauge() is called. Also removes the now-unnecessary # type: ignore[arg-type] comment. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_get_gauge() called on first HTTP request"] --> B{"Already attempted init?"}
B -- Yes --> C["Return cached _gauge"]
B -- No --> D["Mark init attempted"]
D --> E["Import prometheus_client.Gauge"]
E --> F["Initialize kwargs = {}"]
F --> G{"PROMETHEUS_MULTIPROC_DIR set?"}
G -- Yes --> H["kwargs['multiprocess_mode'] = 'livesum'"]
H --> I["Create Gauge(**kwargs)"]
G -- No --> I
I --> J["Return _gauge"]
E -- ImportError --> K["_gauge = None"]
K --> J
Last reviewed commit: 22140b0
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
Fix undefined kwargs in InFlightRequestsMiddleware
This branch had an error being deployed
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.
Summary
kwargswas referenced on lines 67 and 71 ofin_flight_requests_middleware.pybut never initialized, causingF821 Undefined namelint errorskwargsas an empty dict before the conditional blockNote: The
router.py:1721 PLR0915 Too many statementserror is a pre-existing style warning and is not addressed here to keep this PR scoped.Test plan
make lint-ruffpasses for this file🤖 Generated with Claude Code