Skip to content

fix(lint): suppress PLR0915 in complex transform methods#22328

Open
jquinter wants to merge 1 commit intomainfrom
fix/ruff-plr0915-too-many-statements
Open

fix(lint): suppress PLR0915 in complex transform methods#22328
jquinter wants to merge 1 commit intomainfrom
fix/ruff-plr0915-too-many-statements

Conversation

@jquinter
Copy link
Collaborator

Summary

  • Suppress Ruff PLR0915 (too-many-statements) on 3 methods that legitimately need many statements for event/message transformation logic
  • streaming_iterator.py::_process_event (84 statements)
  • transformation.py::translate_messages_to_responses_input (51 statements)
  • transformation.py::transform_realtime_response (54 statements)

These are complex transformation methods where splitting would reduce readability. Suppressing the lint warning is the appropriate fix.

Test plan

  • ruff check passes with no PLR0915 errors
  • CI lint job passes

🤖 Generated with Claude Code

@vercel
Copy link

vercel bot commented Feb 28, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 28, 2026 2:19am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Suppresses Ruff PLR0915 (too-many-statements) lint warnings on three complex event/message transformation methods by adding inline # noqa: PLR0915 comments. No functional code changes.

  • _process_event in streaming_iterator.py (84 statements): dispatches Responses API events to Anthropic chunk format
  • translate_messages_to_responses_input in transformation.py (51 statements): converts Anthropic messages to Responses API input items
  • transform_realtime_response in Gemini transformation.py (54 statements): transforms Gemini realtime events to OpenAI format

This follows the well-established codebase pattern — there are 100+ existing # noqa: PLR0915 suppressions across the project for similar complex transformation/dispatch methods.

Confidence Score: 5/5

  • This PR is safe to merge — it only adds lint suppression comments with zero functional code changes.
  • The PR makes 3 single-character-range changes (adding # noqa: PLR0915 comments) with no functional impact. The suppressed methods are legitimate complex dispatchers where the statement count is inherent to the problem domain. The pattern is widely established in this codebase (100+ existing suppressions).
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/anthropic/experimental_pass_through/responses_adapters/streaming_iterator.py Adds # noqa: PLR0915 to _process_event method (84 statements) — a complex event-type dispatcher where splitting would reduce readability. No functional changes.
litellm/llms/anthropic/experimental_pass_through/responses_adapters/transformation.py Adds # noqa: PLR0915 to translate_messages_to_responses_input method (51 statements) — a message format translator with many branches. No functional changes.
litellm/llms/gemini/realtime/transformation.py Adds # noqa: PLR0915 to transform_realtime_response method (54 statements) — a realtime event transformer with many event type branches. No functional changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Ruff Lint Check] --> B{PLR0915 too-many-statements}
    B -->|streaming_iterator.py| C["_process_event\n84 statements\n# noqa: PLR0915"]
    B -->|transformation.py\nAnthropic| D["translate_messages_to_responses_input\n51 statements\n# noqa: PLR0915"]
    B -->|transformation.py\nGemini| E["transform_realtime_response\n54 statements\n# noqa: PLR0915"]
    C --> F[Lint passes ✓]
    D --> F
    E --> F
Loading

Last reviewed commit: 21b21d7

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.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@jquinter
Copy link
Collaborator Author

@shin-bot-litellm evaluate this PR

…methods

These three methods legitimately need many statements for their
event/message transformation logic. Suppress the lint warning rather
than artificially splitting the methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jquinter
Copy link
Collaborator Author

CI Failure: MCP test failures

These 3 MCP test failures are pre-existing on main and unrelated to this PR's lint suppression changes.

Root cause: Tests mock filter_server_ids_by_ip (old method name) but the code now calls filter_server_ids_by_ip_with_info (returns a tuple).

Fix PR: #22327

@jquinter
Copy link
Collaborator Author

CI Failure: MyPy type errors (21 errors in 9 files)

These MyPy errors are pre-existing on main and unrelated to this PR. This PR only adds # noqa: PLR0915 comments (Ruff lint suppressions), which cannot introduce MyPy type errors.

The 21 errors span 9 files across the codebase:

  • proxy/middleware/in_flight_requests_middleware.py (4 errors)
  • responses_adapters/transformation.py (2 errors)
  • responses_adapters/streaming_iterator.py (2 errors)
  • responses_adapters/handler.py (1 error)
  • litellm_core_utils/realtime_streaming.py (3 errors)
  • completion_extras/litellm_responses_transformation/transformation.py (2 errors)
  • proxy/auth/user_api_key_auth.py (2 errors)
  • proxy/public_endpoints/public_endpoints.py (3 errors)
  • proxy/management_endpoints/project_endpoints.py (2 errors)

All verified to exist on main.

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