From b6ba8aa36c2336a3cf64611d7c8ff78d73d6ea7e Mon Sep 17 00:00:00 2001 From: yucheng Date: Thu, 16 Jul 2026 23:56:40 +0000 Subject: [PATCH] chore: satisfy strict type syntax lint Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- basedpyright-code-budget.json | 2 +- litellm/models/organization.py | 2 +- litellm/models/team.py | 2 +- litellm/models/verification_token.py | 2 +- litellm/proxy/_types.py | 10 +++++----- litellm/proxy/credential_endpoints/endpoints.py | 14 +++++++------- litellm/proxy/litellm_pre_call_utils.py | 6 +++--- litellm/proxy/management_endpoints/common_utils.py | 2 +- .../key_management_endpoints.py | 4 ++-- ruff-strict-budget.json | 8 ++++---- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json index edfb3536ad3..4ee46aace4d 100644 --- a/basedpyright-code-budget.json +++ b/basedpyright-code-budget.json @@ -24,7 +24,7 @@ "limit": 42 }, "reportExplicitAny": { - "limit": 10397 + "limit": 10396 }, "reportFunctionMemberAccess": { "limit": 11 diff --git a/litellm/models/organization.py b/litellm/models/organization.py index c211b69dd0c..0df2248350e 100644 --- a/litellm/models/organization.py +++ b/litellm/models/organization.py @@ -22,7 +22,7 @@ class LiteLLM_OrganizationTable(LiteLLMPydanticObjectBase): spend: float = 0.0 metadata: Optional[dict] = None models: List[str] = [] - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None model_spend: Optional[dict] = {} created_by: str updated_by: str diff --git a/litellm/models/team.py b/litellm/models/team.py index 435d769f979..f0dcd1b68f4 100644 --- a/litellm/models/team.py +++ b/litellm/models/team.py @@ -92,7 +92,7 @@ class LiteLLM_TeamTable(TeamBase): model_spend: Optional[dict] = {} model_max_budget: Optional[dict] = {} policies: Optional[List[str]] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None allow_team_guardrail_config: Optional[bool] = False litellm_model_table: Optional[LiteLLM_ModelTable] = None object_permission: Optional[LiteLLM_ObjectPermissionTable] = None diff --git a/litellm/models/verification_token.py b/litellm/models/verification_token.py index 84a287697b1..f15c9c03092 100644 --- a/litellm/models/verification_token.py +++ b/litellm/models/verification_token.py @@ -54,7 +54,7 @@ class LiteLLM_VerificationToken(LiteLLMPydanticObjectBase): object_permission_id: Optional[str] = None object_permission: Optional[LiteLLM_ObjectPermissionTable] = None access_group_ids: Optional[List[str]] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None rotation_count: Optional[int] = 0 auto_rotate: Optional[bool] = False rotation_interval: Optional[str] = None diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 1a93be6b3ac..e780a9bbb04 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -1080,7 +1080,7 @@ class AllowedVectorStoreIndexItem(LiteLLMPydanticObjectBase): class KeyRequestBase(GenerateRequestBase): key: Optional[str] = None budget_id: Optional[str] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None tags: Optional[List[str]] = None disable_global_guardrails: Optional[bool] = None throttle_on_budget_exceeded: Optional[bool] = None @@ -1775,7 +1775,7 @@ class NewTeamRequest(TeamBase): tags: Optional[list] = None guardrails: Optional[List[str]] = None policies: Optional[List[str]] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None prompts: Optional[List[str]] = None object_permission: Optional[LiteLLM_ObjectPermissionBase] = None allowed_passthrough_routes: Optional[list] = None @@ -1842,7 +1842,7 @@ class UpdateTeamRequest(LiteLLMPydanticObjectBase): model_aliases: Optional[dict] = None guardrails: Optional[List[str]] = None policies: Optional[List[str]] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None object_permission: Optional[LiteLLM_ObjectPermissionBase] = None disable_global_guardrails: Optional[bool] = None team_member_budget: Optional[float] = None @@ -1986,7 +1986,7 @@ class NewOrganizationRequest(LiteLLM_BudgetTable): models: List = [] budget_id: Optional[str] = None metadata: Optional[dict] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None model_rpm_limit: Optional[Dict[str, int]] = None model_tpm_limit: Optional[Dict[str, int]] = None @@ -2752,7 +2752,7 @@ class LiteLLM_OrganizationTableUpdate(LiteLLM_BudgetTable): spend: Optional[float] = None metadata: Optional[dict] = None models: Optional[List[str]] = None - logging_exporters: Optional[list[str]] = None + logging_exporters: list[str] | None = None updated_by: Optional[str] = None object_permission: Optional[LiteLLM_ObjectPermissionBase] = None model_tpm_limit: Optional[Dict[str, int]] = None diff --git a/litellm/proxy/credential_endpoints/endpoints.py b/litellm/proxy/credential_endpoints/endpoints.py index 0b780b3a9db..dd369554544 100644 --- a/litellm/proxy/credential_endpoints/endpoints.py +++ b/litellm/proxy/credential_endpoints/endpoints.py @@ -81,7 +81,7 @@ class CallerAdminScope: async def _caller_admin_scope( - user_api_key_dict: UserAPIKeyAuth, prisma_client: "Optional[PrismaClient]" + user_api_key_dict: UserAPIKeyAuth, prisma_client: "PrismaClient | None" ) -> CallerAdminScope: """The teams and orgs the caller administers. @@ -153,21 +153,21 @@ async def _caller_admin_scope( async def _caller_grantable_team_ids( - user_api_key_dict: UserAPIKeyAuth, prisma_client: "Optional[PrismaClient]" + user_api_key_dict: UserAPIKeyAuth, prisma_client: "PrismaClient | None" ) -> frozenset[str]: """Team ids the caller may add to / remove from a destination's ``access.teams`` (the PATCH decider's grant scope).""" return (await _caller_admin_scope(user_api_key_dict, prisma_client)).team_ids -def _credential_in_memory(credential_name: str) -> Optional[CredentialItem]: +def _credential_in_memory(credential_name: str) -> CredentialItem | None: return next( (cred for cred in litellm.credential_list if cred.credential_name == credential_name), None, ) -async def _credential_for_admin_gate(credential_name: str, prisma_client: object) -> Optional[CredentialItem]: +async def _credential_for_admin_gate(credential_name: str, prisma_client: object) -> CredentialItem | None: """Authoritative credential lookup for the admin gate on update/delete. The in-process ``litellm.credential_list`` can be stale: a credential created @@ -526,9 +526,9 @@ async def _authorize_credential_patch( *, credential_name: str, patch: UpdateCredentialItem, - existing: Optional[CredentialItem], + existing: CredentialItem | None, user_api_key_dict: UserAPIKeyAuth, - prisma_client: "Optional[PrismaClient]", + prisma_client: "PrismaClient | None", ) -> None: """Raise 403 unless the caller is allowed to apply ``patch`` to ``existing``. @@ -660,7 +660,7 @@ def _sync_in_memory_credential( ``_merge_credential_info`` so a partial patch can't clobber stored ``access`` subfields it didn't touch. """ - existing_in_memory: Optional[CredentialItem] = None + existing_in_memory: CredentialItem | None = None for cred in litellm.credential_list: if cred.credential_name == old_name: existing_in_memory = cred diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py index e07ca782a2d..b6944f5c8f8 100644 --- a/litellm/proxy/litellm_pre_call_utils.py +++ b/litellm/proxy/litellm_pre_call_utils.py @@ -534,7 +534,7 @@ class KeyAndTeamLoggingSettings: return None -async def _effective_org_id(user_api_key_dict: UserAPIKeyAuth) -> Optional[str]: +async def _effective_org_id(user_api_key_dict: UserAPIKeyAuth) -> str | None: """The org this request belongs to, falling back to the team's org when the token carries none. Team keys frequently have no ``org_id`` on the token, so without this an org-scoped destination would be invisible at request time even though the write @@ -563,7 +563,7 @@ async def _effective_org_id(user_api_key_dict: UserAPIKeyAuth) -> Optional[str]: return getattr(team_obj, "organization_id", None) -async def _union_logging_exporter_names(user_api_key_dict: UserAPIKeyAuth, org_id: Optional[str]) -> set: +async def _union_logging_exporter_names(user_api_key_dict: UserAPIKeyAuth, org_id: str | None) -> set: """The union of admin-assigned exporter names across the request's identity chain. Each level is read from its own ``logging_exporters`` column: the key via @@ -686,7 +686,7 @@ async def _resolve_logging_exporters( def _build( credential: "CredentialItem", - ) -> "Optional[tuple[str, OtelDestination]]": + ) -> "tuple[str, OtelDestination] | None": backend = (credential.credential_info or {}).get("description") if not backend: return None diff --git a/litellm/proxy/management_endpoints/common_utils.py b/litellm/proxy/management_endpoints/common_utils.py index d8ff82c6b6e..2fe2203bf4c 100644 --- a/litellm/proxy/management_endpoints/common_utils.py +++ b/litellm/proxy/management_endpoints/common_utils.py @@ -111,7 +111,7 @@ def _is_user_team_admin(user_api_key_dict: UserAPIKeyAuth, team_obj: LiteLLM_Tea return False -async def _is_user_org_admin_for_org_id(user_api_key_dict: UserAPIKeyAuth, organization_id: Optional[str]) -> bool: +async def _is_user_org_admin_for_org_id(user_api_key_dict: UserAPIKeyAuth, organization_id: str | None) -> bool: """Check if the caller has the ORG_ADMIN role in the given organization. Returns False when ``organization_id`` is falsy or the caller has no user_id, diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index da49e642d20..b32b26138a1 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -3683,7 +3683,7 @@ async def generate_key_helper_fn( rotation_interval: Optional[str] = None, router_settings: Optional[dict] = None, access_group_ids: Optional[list] = None, - logging_exporters: Optional[list] = None, # admin-owned OTEL destinations (credential names) + logging_exporters: list | None = None, # admin-owned OTEL destinations (credential names) budget_limits: Optional[list] = None, # multiple concurrent budget windows ): from litellm.proxy.proxy_server import premium_user, prisma_client @@ -4840,7 +4840,7 @@ async def regenerate_key_fn( # noqa: C901 # single endpoint handling many opti # Look up the key's team once (the body may omit team_id); shared by the # access-group, object-permission, and logging-exporter gates below. - regenerate_team_table: Optional[LiteLLM_TeamTableCachedObj] = None + regenerate_team_table: LiteLLM_TeamTableCachedObj | None = None if _key_in_db.team_id is not None: try: regenerate_team_table = await get_team_object( diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json index dcde6fd1641..43e25f6b5da 100644 --- a/ruff-strict-budget.json +++ b/ruff-strict-budget.json @@ -24,7 +24,7 @@ "limit": 130 }, "ANN401": { - "limit": 2075 + "limit": 2074 }, "ASYNC230": { "limit": 14 @@ -237,7 +237,7 @@ "limit": 41 }, "RUF022": { - "limit": 85 + "limit": 84 }, "RUF023": { "limit": 5 @@ -306,7 +306,7 @@ "limit": 9 }, "TID251": { - "limit": 2701 + "limit": 2700 }, "TRY002": { "limit": 548 @@ -363,6 +363,6 @@ "limit": 105 }, "UP045": { - "limit": 18462 + "limit": 18458 } }