Repository navigation
refactor: expose core private helpers under public names - #44871
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…_core Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # litellm/litellm_core_utils/litellm_logging.py # litellm/llms/openai/responses/transformation.py # litellm/llms/openai_like/model_info.py # litellm/router.py
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>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
bugbot run |
|
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>
|
bugbot run |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
bugbot run |
|
@greptileai Please review the latest pushed changes at 10003e3 and report any actionable concerns on the PR |
|
bugbot run Please review the latest pushed changes at 10003e3 and report any new issues on the PR |
|
bugbot run |
…_core Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # tests/unit/litellm_core_utils/test_core_helpers.py
|
bugbot run |
|
bugbot run |
|
@greptileai the run picker and heuristic fallback findings come from main's dashboard commits merged in. This PR's diff against its merge base touches no ui/ files |
…_core Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # litellm/router.py
|
bugbot run |
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 9ba5e40. Configure here.
TLDR
Problem this solves:
reportPrivateUsagesits at 1,804 on main, and about 600 of those hits are core code (litellm root, router, caching, integrations, enterprise) importing or calling another module's underscore helpersHow it solves it:
_old = newfor functions, classes and methods, a forwarding property for plain instance attributes), so enterprise, proxy-extras and user code that imports the old name is unaffected.tests/unit/test_private_usage_aliases.pyasserts every alias is the identical object and every property round-trips_parsing, prometheus_client_nameand_names_to_collectors) get exact-rulepyright: ignore[reportPrivateUsage]with a reasonlitellm._async_success_callback,litellm._custom_providers), since assigning a new value to the old name would not reach the new one, pydantic private attributes, name collisions, and 16 helpers whose untyped signatures would have raised other rule countsreportPrivateUsage1,804 to 1,384 on the gate's basedpyright. The budget file is untouched, the ratchet lowers it after mergeUser Flow
Before: an SDK user or enterprise callback imports a helper by its underscore name
from litellm.utils import _get_model_cost_keyorlitellm._should_retry(429)After: the same imports work and a public name exists
from litellm.utils import _get_model_cost_keystill works and is the same function asget_model_cost_keyPre-Submission checklist
Caveats
Screenshots / Proof of Fix
Live before and after video goes in the Slack thread https://berriaillm.slack.com/archives/C0B302ZJU05/p1791232426675779
Link to Devin session: https://app.devin.ai/sessions/32b275f5ec964f1f82cf6192e19a6237
Open in Devin Desktop: https://app.devin.ai/desktop/session/32b275f5ec964f1f82cf6192e19a6237?variant=devin
Requested by: @mateo-berri
Note
Medium Risk
Large, cross-cutting rename with alias preservation—low logic change—but it touches caching, batch cost attribution, and logging/redaction paths where a missed caller or alias could cause subtle breakage.
Overview
This PR promotes cross-module underscore helpers to public names across LiteLLM core and enterprise (logging, lazy imports, caching, batch/file utilities, cost calculator, integrations, enterprise proxy hooks) and updates in-tree callers to use the new names.
Backward compatibility is preserved by assigning each old symbol to the new one (
_turn_on_debug = turn_on_debug,_PROXY_LiteLLMManagedFiles = PROXY_LiteLLMManagedFiles, lazy-import registry entries that map both_should_retryandshould_retry, etc.), so existingfrom litellm... import _foopatterns keep working.Alongside the renames, the diff adds typing tightening in touched paths—
TypedDict/Protocolfor file and Prisma helpers,cast/Final, and stricter callbackCallable[..., object]types—without changing the described runtime behavior of proxy, caching, or batch cost tracking.Enterprise-facing renames include managed files/vector store hook classes (dropping the leading underscore on the primary class name),
should_block_robots, and call sites switched from private logging/tag helpers (e.g.get_request_tags,get_vector_stores_from_db).Reviewed by Cursor Bugbot for commit 9ba5e40. Bugbot is set up for automated code reviews on this repo. Configure here.