fix(types): drop restating docstrings, import search tool types at runtime, close the spend-table match

This commit is contained in:
mateo-berri 2026-09-21 13:44:58 -07:00
parent 56d1f042ef
commit b8c793b962
4 changed files with 7 additions and 19 deletions

View file

@ -43,8 +43,6 @@ TERMINAL_MANAGED_OBJECT_STATUSES: Final[Tuple[str, ...]] = (
class _ManagedObjectRow(Protocol):
"""The managed-object row fields this poller reads off whatever the DB hands back."""
@property
def id(self) -> str: ...
@ -59,19 +57,16 @@ class _ManagedObjectRow(Protocol):
def _managed_object_table(prisma_client: "PrismaClient") -> "TableActions[_ManagedObjectRow]":
"""The managed-object table's prisma actions, typed to the row fields this module reads."""
table: Final[TableActions[_ManagedObjectRow]] = prisma_client.db.litellm_managedobjecttable
return table
def _user_table(prisma_client: "PrismaClient") -> "TableActions[prisma_models.LiteLLM_UserTable]":
"""The user table's prisma actions."""
table: Final[TableActions[prisma_models.LiteLLM_UserTable]] = prisma_client.db.litellm_usertable
return table
def _token_table(prisma_client: "PrismaClient") -> "TableActions[prisma_models.LiteLLM_VerificationToken]":
"""The virtual-key table's prisma actions."""
table: Final[TableActions[prisma_models.LiteLLM_VerificationToken]] = (
prisma_client.db.litellm_verificationtoken
)
@ -79,7 +74,6 @@ def _token_table(prisma_client: "PrismaClient") -> "TableActions[prisma_models.L
def _team_table(prisma_client: "PrismaClient") -> "TableActions[prisma_models.LiteLLM_TeamTable]":
"""The team table's prisma actions."""
table: Final[TableActions[prisma_models.LiteLLM_TeamTable]] = prisma_client.db.litellm_teamtable
return table

View file

@ -29,8 +29,6 @@ TERMINAL_RESPONSE_STATUSES = frozenset({"completed", "failed", "cancelled", "inc
class _ManagedObjectRow(Protocol):
"""The managed-object row fields this poller reads off whatever the DB hands back."""
@property
def id(self) -> str: ...
@ -45,7 +43,6 @@ class _ManagedObjectRow(Protocol):
def _managed_object_table(prisma_client: "PrismaClient") -> "TableActions[_ManagedObjectRow]":
"""The managed-object table's prisma actions, typed to the row fields this poller reads."""
table: Final[TableActions[_ManagedObjectRow]] = prisma_client.db.litellm_managedobjecttable
return table

View file

@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any, Final, Literal, Protocol, TypeAlias, Type
from urllib.parse import quote, unquote
from pydantic import TypeAdapter
from typing_extensions import LiteralString, ReadOnly, TypedDict
from typing_extensions import LiteralString, ReadOnly, TypedDict, assert_never
import litellm
from litellm._logging import verbose_proxy_logger
@ -142,7 +142,6 @@ _EntitySpendTable: TypeAlias = Literal[
def _entity_spend_table(batcher: _SpendBatch, table_accessor: _EntitySpendTable) -> BatchTable:
"""The batch table an entity type's spend increments are written to."""
match table_accessor:
case "litellm_tagtable":
return batcher.litellm_tagtable
@ -152,6 +151,8 @@ def _entity_spend_table(batcher: _SpendBatch, table_accessor: _EntitySpendTable)
return batcher.litellm_modelaccessgroupbudgettable
case "litellm_projecttable":
return batcher.litellm_projecttable
case _ as unreachable:
assert_never(unreachable)
class _SpendBatchManager(Protocol):

View file

@ -10,18 +10,16 @@ import traceback
from collections.abc import Callable
from functools import partial
from types import MappingProxyType
from typing import TYPE_CHECKING, Any, Final, Protocol
from typing import Any, Final, Protocol
from litellm._logging import verbose_router_logger
if TYPE_CHECKING:
from litellm.types.router import SearchToolLiteLLMParams, SearchToolTypedDict
from litellm.types.router import SearchToolLiteLLMParams, SearchToolTypedDict
class _SearchToolsRouter(Protocol):
"""The one router attribute the search-tool helpers read and replace."""
search_tools: "list[SearchToolTypedDict]"
search_tools: list[SearchToolTypedDict]
class SearchAPIRouter:
@ -34,7 +32,7 @@ class SearchAPIRouter:
@staticmethod
def _resolve_search_provider_credentials(
*,
tool_litellm_params: "SearchToolLiteLLMParams",
tool_litellm_params: SearchToolLiteLLMParams,
) -> tuple[str | None, str | None]:
"""
Resolve search provider credentials from tool configuration ONLY.
@ -65,8 +63,6 @@ class SearchAPIRouter:
search_tools: List of search tool configurations from the database
"""
try:
from litellm.types.router import SearchToolTypedDict
verbose_router_logger.debug("Adding %s search tools to router", len(search_tools))
# Convert search tools to the format expected by the router