mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-13 03:59:12 +00:00
* refactor(types): move LitellmUserRoles and KeyManagementRoutes into litellm.types.proxy.auth.user_roles Part of LIT-9423 * refactor(types): move is_jwt into litellm.types.proxy.auth.user_api_key_auth Part of LIT-9423 * refactor(auth): alias is_jwt import so JWTHandler.is_jwt is not read as recursive * refactor(types): type UserAPIKeyAuth, its token view and hash_token in place Part of LIT-9423 * refactor(types): move UserAPIKeyAuth, its token view and hash_token into litellm.types.proxy.auth.user_api_key_auth Part of LIT-9423 * fix(types): keep agent, budget snapshot and is_jwt names importable from proxy._types Part of LIT-9423 * refactor(core_utils): move resource_ownership out of the proxy Part of LIT-9423 * fix(types): restore main's _types.py content alongside the user_api_key_auth move Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(sdk): resolve litellm.proxy lazily on attribute access The layer cleanup stopped import litellm from loading any proxy module, so litellm.proxy was no longer bound and litellm.proxy._types.X raised AttributeError. The module __getattr__ now imports litellm.proxy on first access, which keeps import litellm free of proxy._types and fixes the docs and code-quality checks on main * fix(sdk): resolve litellm.proxy lazily on attribute access The layer cleanup stopped import litellm from loading any proxy module, so litellm.proxy was no longer bound and litellm.proxy._types.X raised AttributeError. The module __getattr__ now imports litellm.proxy on first access, which keeps import litellm free of proxy._types and fixes the docs and code-quality checks on main * style(types): drop blank lines between proxy._types re-export imports Part of LIT-9423 * refactor(proxy): keep only user_api_key_auth re-exports in _types.py Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(proxy): carry main's UserAPIKeyAuth field into moved file Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * style(types): drop blank lines between proxy._types re-export imports Part of LIT-9423 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
29 lines
969 B
Python
29 lines
969 B
Python
from typing import Final
|
|
|
|
from litellm.litellm_core_utils import resource_ownership as core_resource_ownership
|
|
from litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuth
|
|
from litellm.proxy.common_utils import resource_ownership as proxy_resource_ownership
|
|
|
|
PREVIOUSLY_EXPOSED_NAMES: Final = (
|
|
"Final",
|
|
"LitellmUserRoles",
|
|
"UserAPIKeyAuth",
|
|
"get_primary_resource_owner_scope",
|
|
"get_resource_owner_scopes",
|
|
"is_proxy_admin",
|
|
"user_can_access_resource_owner",
|
|
)
|
|
|
|
|
|
def test_proxy_path_reexports_core_objects() -> None:
|
|
mismatched: Final = [
|
|
name
|
|
for name in PREVIOUSLY_EXPOSED_NAMES
|
|
if getattr(proxy_resource_ownership, name) is not getattr(core_resource_ownership, name)
|
|
]
|
|
assert mismatched == []
|
|
|
|
|
|
def test_moved_module_uses_the_proxy_types_objects() -> None:
|
|
assert core_resource_ownership.LitellmUserRoles is LitellmUserRoles
|
|
assert core_resource_ownership.UserAPIKeyAuth is UserAPIKeyAuth
|