Skip to content

fix(lint): suppress PLR0915 too many statements in route_request#21390

Merged
jquinter merged 1 commit intomainfrom
fix/lint-too-many-statements-route-llm
Feb 17, 2026
Merged

fix(lint): suppress PLR0915 too many statements in route_request#21390
jquinter merged 1 commit intomainfrom
fix/lint-too-many-statements-route-llm

Conversation

@jquinter
Copy link
Contributor

Problem

Lint error blocking CI:

proxy/route_llm_request.py:145:11: PLR0915 Too many statements (60 > 50)

Solution

Add # noqa: PLR0915 comment to suppress the "too many statements" warning.

Why Not Refactor?

The route_request() function is 305 lines and handles routing for 50+ different request types:

  • acompletion, aembedding, aimage_generation, aspeech, atranscription
  • arerank, aresponses, avector_store_*, aocr, asearch
  • avideo_*, acontainer_*, askill_*, aingest
  • aevals, aruns, and many more...

Refactoring this properly would require:

  1. Careful analysis of all route types
  2. Extraction of common patterns
  3. Extensive testing across all 50+ routes
  4. Potential breaking changes

This is better suited for a dedicated refactoring effort, not a lint fix PR.

Impact

  • ✅ Resolves lint error blocking CI
  • ✅ No functional changes
  • ✅ Documents that refactoring should be done separately

Related

Add noqa comment for "too many statements" lint error in route_request().
The function has 60 statements (limit is 50) but refactoring it properly
would be a significant undertaking requiring careful testing.

The function handles routing for 50+ different request types and contains
complex logic that should be addressed in a dedicated refactoring effort,
not as part of a lint fix.

Error: proxy/route_llm_request.py:145:11: PLR0915 Too many statements (60 > 50)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 17, 2026 5:39pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 17, 2026

Greptile Summary

This PR adds a # noqa: PLR0915 inline suppression comment to the route_request() function in litellm/proxy/route_llm_request.py to resolve a CI-blocking lint error ("Too many statements (60 > 50)").

  • The change is a single-line comment addition with zero functional impact
  • This follows the established codebase pattern — there are 100+ other uses of # noqa: PLR0915 across the project (e.g., in litellm/main.py, litellm/router.py, litellm/proxy/proxy_server.py)
  • The route_request() function handles routing for 50+ different request types via a large Literal type and corresponding if/elif chain, making it inherently statement-heavy
  • The comment includes a note that refactoring is tracked separately, which is appropriate for this kind of suppression

Confidence Score: 5/5

  • This PR is entirely safe to merge — it only adds a lint suppression comment with no code behavior changes.
  • The change is a single-line comment addition (# noqa: PLR0915) that suppresses a lint warning. There are zero functional changes, zero risk of regressions, and this pattern is used extensively throughout the codebase (100+ instances). The lint rule PLR0915 is explicitly enabled in ruff.toml and routinely suppressed on large routing/dispatch functions.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/route_llm_request.py Adds # noqa: PLR0915 comment to suppress "too many statements" lint warning on the route_request() function. No functional changes. Follows the established pattern used across 100+ other functions in this codebase.

Flowchart

flowchart TD
    A[PR Change: route_llm_request.py] --> B[route_request function definition]
    B --> C{PLR0915 lint check}
    C -->|Before PR| D[FAIL: 60 statements > 50 max]
    C -->|After PR| E["PASS: # noqa: PLR0915 suppresses warning"]
    D --> F[CI blocked]
    E --> G[CI passes]
Loading

Last reviewed commit: 289341d

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jquinter jquinter merged commit cd20dde into main Feb 17, 2026
17 of 25 checks passed
jquinter added a commit that referenced this pull request Feb 17, 2026
Add two detailed guides for addressing CI test flakiness:

1. test-flakiness-guide.md - Developer guide with:
   - How to use @pytest.mark.no_parallel for async mocks
   - Patterns for robust async mock setup
   - Retry logic strategies
   - Module reload issues and fixes
   - Quick reference and checklist

2. ci-test-improvements.md - Implementation plan with:
   - Priority phased rollout (Quick wins → CI → Enforcement)
   - pytest-rerunfailures plugin setup
   - GitHub Actions improvements for retries
   - Makefile targets for testing
   - Pre-commit hooks for test quality
   - Test utilities module with decorators
   - Success metrics and monitoring

These guides provide actionable solutions for the CI test failures
observed in PRs #21107, #21388, and #21390.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant