Skip to content

refactor: drop slop comments and string getattr from fresh code - #53552

Merged
devin-ai-integration[bot] merged 4 commits into
mainfrom
litellm_techdebt_20261122
Nov 22, 2026
Merged

devin-ai-integration[bot] merged 4 commits into
mainfrom
litellm_techdebt_20261122

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Cleans up tech debt that landed on main in the last day, without changing behavior. It removes comments that only restate the code and replaces string-based attribute lookups on auth objects with typed access, so the type checker sees those reads

Details

Link to Devin session: https://app.devin.ai/sessions/f1fcb79deb994266b3535a3c3aeae521
Open in Devin Desktop: https://app.devin.ai/desktop/session/f1fcb79deb994266b3535a3c3aeae521?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

  • Fresh code from the last 24 hours added slop comments
  • Fresh auth code read metadata through string getattr

How it solves it:

  • Deletes three comments that restate constants and a hash call
  • Reads metadata through a typed helper, same None fallback

Findings (run 2026-11-22)

Window was 99 non-merge commits on main since 897fb20.

4420a5ac5a (feat(vertex_ai): add Meta Muse models on Vertex AI, #50768) added three comments in litellm/litellm_core_utils/tool_fields.py that only restate the code, the 64-character limit note above OPENAI_MAX_TOOL_NAME_LENGTH, the # 55 after the derived prefix length, and the "deterministic hash" note in truncate_tool_name. All three are removed.

fc7f1a575f (feat(proxy): require customer headers by gateway, team, or key, #53045) added four getattr(x, "metadata", None) reads in litellm/proxy/auth/auth_checks.py, in missing_required_customer_header and common_checks, on objects whose types already declare metadata. They now go through _scope_metadata, which returns scope.metadata or None when the object is missing, so the result is the same.

The branch also carries a generated refresh of litellm/proxy/_lazy_openapi_snapshot.json and the dashboard schema.d.ts. Both were already stale on main at d192d5e (byte-identical output from the generators there), and make check fails without them.

Left alone on purpose. The -> Any overloads in litellm/proxy/common_utils/user_api_key_cache.py (lines 180, 196) need caller analysis before they can be typed. The task-retention suppression in litellm/proxy/realtime_endpoints/sideband.py:27 is genuinely needed. gradium_models in litellm/__init__.py keeps its # mutable-ok since add_known_models() adds to it after import. The unused-import suppression on cache_key_object in litellm/proxy/auth/resolvers/store.py was dropped from the batch, since replacing it with an alias while its sibling suppressions stay would only move the debt.

Pre-Submission checklist

  • The handful of test files covering my change pass locally
  • My PR's scope is as isolated as possible; it only solves 1 specific problem

Screenshots / Proof of Fix

E2E exception at 7934b46. The diff deletes comments and swaps four getattr reads for direct attribute reads with the same None fallback, with no behavior change, so focused checks cover it. make lint passes (every basedpyright rule within its ceiling) and make check passes. LITELLM_LOCAL_MODEL_COST_MAP=True uv run --no-sync pytest tests/unit/proxy/auth/test_auth_checks.py tests/unit/proxy/auth/test_user_api_key_auth_request_flow.py tests/unit/proxy/auth/test_resolvers_store.py plus the tool_fields tests ran 1067 passed.

Type

🧹 Refactoring


Note

Low Risk
Comment-only and typing cleanup in tool naming and auth header checks with equivalent runtime behavior; OpenAPI snapshot is generated refresh.

Overview
Strips three redundant comments in tool_fields.py around tool-name length constants and hashing; behavior of truncate_tool_name is unchanged.

In proxy auth, customer-header resolution no longer uses getattr(..., "metadata", None) on team and key objects. A small _MetadataScope protocol and _scope_metadata return metadata or None the same way, with direct attribute access for the type checker. Four call sites in missing_required_customer_header and common_checks are updated.

The _lazy_openapi_snapshot.json diff is a regenerated snapshot (e.g. documents POST /v1/live/sessions); not a functional change bundled with the refactor beyond keeping make check green.

Reviewed by Cursor Bugbot for commit 7934b46. Bugbot is set up for automated code reviews on this repo. Configure here.

mateo-berri and others added 4 commits November 22, 2026 08:23
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@veria-ai

veria-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This PR appears safe to merge.

Summary

This PR removes redundant comments and replaces four string-based metadata reads with a typed helper. It also refreshes generated OpenAPI and dashboard types for existing server features.

No actionable issues were found.

  • Customer-header checks read team and key metadata through declared fields.
  • Tool-name limits and hashing are shown by the code, not repeated in comments.
  • Generated API descriptions include the live-session route and WebRTC metering setting.

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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 7934b46. Configure here.

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@devin-ai-integration
devin-ai-integration Bot merged commit 6df435f into main Nov 22, 2026
55 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the litellm_techdebt_20261122 branch November 22, 2026 08:56
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