chore: satisfy strict type syntax lint

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
yucheng 2026-07-16 23:56:40 +00:00
parent b56ee768d4
commit b6ba8aa36c
10 changed files with 26 additions and 26 deletions

View file

@ -24,7 +24,7 @@
"limit": 42
},
"reportExplicitAny": {
"limit": 10397
"limit": 10396
},
"reportFunctionMemberAccess": {
"limit": 11

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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(

View file

@ -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
}
}