Repository navigation
refactor: drop slop comments and string getattr from fresh code - #53552
Merged
Merged
Conversation
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>
Contributor
PR overviewNo security issues were found in this pull request. Reviews
|
Contributor
Contributor
|
bugbot run |
Contributor
[Low impact] This PR appears safe to merge.
|
Contributor
There was a problem hiding this comment.
✅ 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.
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.
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:
metadatathrough stringgetattrHow it solves it:
metadatathrough a typed helper, sameNonefallbackFindings (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 inlitellm/litellm_core_utils/tool_fields.pythat only restate the code, the 64-character limit note aboveOPENAI_MAX_TOOL_NAME_LENGTH, the# 55after the derived prefix length, and the "deterministic hash" note intruncate_tool_name. All three are removed.fc7f1a575f(feat(proxy): require customer headers by gateway, team, or key, #53045) added fourgetattr(x, "metadata", None)reads inlitellm/proxy/auth/auth_checks.py, inmissing_required_customer_headerandcommon_checks, on objects whose types already declaremetadata. They now go through_scope_metadata, which returnsscope.metadataorNonewhen the object is missing, so the result is the same.The branch also carries a generated refresh of
litellm/proxy/_lazy_openapi_snapshot.jsonand the dashboardschema.d.ts. Both were already stale on main at d192d5e (byte-identical output from the generators there), andmake checkfails without them.Left alone on purpose. The
-> Anyoverloads inlitellm/proxy/common_utils/user_api_key_cache.py(lines 180, 196) need caller analysis before they can be typed. The task-retention suppression inlitellm/proxy/realtime_endpoints/sideband.py:27is genuinely needed.gradium_modelsinlitellm/__init__.pykeeps its# mutable-oksinceadd_known_models()adds to it after import. The unused-import suppression oncache_key_objectinlitellm/proxy/auth/resolvers/store.pywas dropped from the batch, since replacing it with an alias while its sibling suppressions stay would only move the debt.Pre-Submission checklist
Screenshots / Proof of Fix
E2E exception at 7934b46. The diff deletes comments and swaps four
getattrreads for direct attribute reads with the sameNonefallback, with no behavior change, so focused checks cover it.make lintpasses (every basedpyright rule within its ceiling) andmake checkpasses.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.pyplus 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.pyaround tool-name length constants and hashing; behavior oftruncate_tool_nameis unchanged.In proxy auth, customer-header resolution no longer uses
getattr(..., "metadata", None)on team and key objects. A small_MetadataScopeprotocol and_scope_metadatareturnmetadataorNonethe same way, with direct attribute access for the type checker. Four call sites inmissing_required_customer_headerandcommon_checksare updated.The
_lazy_openapi_snapshot.jsondiff is a regenerated snapshot (e.g. documentsPOST /v1/live/sessions); not a functional change bundled with the refactor beyond keepingmake checkgreen.Reviewed by Cursor Bugbot for commit 7934b46. Bugbot is set up for automated code reviews on this repo. Configure here.