diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.json index c245bd4624b..8894edd0d24 100644 --- a/basedpyright-code-budget.json +++ b/basedpyright-code-budget.json @@ -1,6 +1,6 @@ { "reportAny": { - "limit": 26879 + "limit": 26575 }, "reportArgumentType": { "limit": 2626 @@ -24,7 +24,7 @@ "limit": 19 }, "reportExplicitAny": { - "limit": 8733 + "limit": 8704 }, "reportFunctionMemberAccess": { "limit": 7 @@ -57,7 +57,7 @@ "limit": 5835 }, "reportMissingTypeArgument": { - "limit": 15757 + "limit": 15746 }, "reportMissingTypeStubs": { "limit": 40 @@ -99,19 +99,19 @@ "limit": 0 }, "reportUnknownArgumentType": { - "limit": 45036 + "limit": 45026 }, "reportUnknownLambdaType": { "limit": 113 }, "reportUnknownMemberType": { - "limit": 39721 + "limit": 39703 }, "reportUnknownParameterType": { - "limit": 20204 + "limit": 20203 }, "reportUnknownVariableType": { - "limit": 31199 + "limit": 31170 }, "reportUnnecessaryCast": { "limit": 122 diff --git a/litellm/repositories/base_repository.py b/litellm/repositories/base_repository.py index ce6673c3b4f..b2d2ec7e906 100644 --- a/litellm/repositories/base_repository.py +++ b/litellm/repositories/base_repository.py @@ -8,7 +8,7 @@ from typing import Any, Final, Generic, Protocol, TypeVar, runtime_checkable from pydantic import BaseModel -from litellm.repositories.prisma_protocols import PrismaTableActions +from litellm.repositories.prisma_protocols import FindManyKwargs, PrismaTableActions T = TypeVar("T", bound=BaseModel) @@ -96,12 +96,17 @@ class BaseRepository(ABC, Generic[T]): order: dict[str, str] | None = None, ) -> list[T]: """Find multiple records matching the criteria.""" - records: Final = await self.typed_table.find_many( - where=where or None, - skip=skip, - take=take, - order=order or None, - ) + kwargs: Final[FindManyKwargs] = {} + if where: + kwargs["where"] = where + if skip is not None: + kwargs["skip"] = skip + if take is not None: + kwargs["take"] = take + if order: + kwargs["order"] = order + + records: Final = await self.typed_table.find_many(**kwargs) return self._to_model_list(records) async def create(self, data: dict[str, Any]) -> T: diff --git a/litellm/repositories/prisma_protocols.py b/litellm/repositories/prisma_protocols.py index e2b7e456f62..80b7b82333b 100644 --- a/litellm/repositories/prisma_protocols.py +++ b/litellm/repositories/prisma_protocols.py @@ -8,7 +8,7 @@ private ones per file. from collections.abc import Mapping, Sequence from datetime import datetime -from typing import Protocol, TypeVar +from typing import Protocol, TypedDict, TypeVar RowT_co = TypeVar("RowT_co", covariant=True) RowT = TypeVar("RowT") @@ -103,6 +103,13 @@ class PrismaTableActions(Protocol): async def count(self, *, where: Mapping[str, object] | None = None) -> int: ... +class FindManyKwargs(TypedDict, total=False): + where: Mapping[str, object] + skip: int + take: int + order: Mapping[str, str] + + class JWTKeyMappingRecord(Protocol): token: str diff --git a/ruff-strict-budget.json b/ruff-strict-budget.json index 224ed6e85f2..e223aa0d60b 100644 --- a/ruff-strict-budget.json +++ b/ruff-strict-budget.json @@ -12,7 +12,7 @@ "limit": 2031 }, "ANN202": { - "limit": 862 + "limit": 861 }, "ANN204": { "limit": 713 @@ -24,7 +24,7 @@ "limit": 133 }, "ANN401": { - "limit": 1514 + "limit": 1499 }, "ASYNC230": { "limit": 11 @@ -57,7 +57,7 @@ "limit": 3 }, "BLE001": { - "limit": 2922 + "limit": 2921 }, "C401": { "limit": 8 @@ -192,7 +192,7 @@ "limit": 0 }, "S110": { - "limit": 216 + "limit": 215 }, "S112": { "limit": 22 @@ -234,7 +234,7 @@ "limit": 5 }, "TID251": { - "limit": 1231 + "limit": 1229 }, "TRY002": { "limit": 528 diff --git a/type-discipline-budget.json b/type-discipline-budget.json index 693a800b1f5..6e6dcd667fa 100644 --- a/type-discipline-budget.json +++ b/type-discipline-budget.json @@ -1,9 +1,9 @@ { "LIT001": { - "limit": 23128 + "limit": 23121 }, "LIT002": { - "limit": 27111 + "limit": 27090 }, "LIT003": { "limit": 269 @@ -15,7 +15,7 @@ "limit": 0 }, "LIT006": { - "limit": 1084 + "limit": 1083 }, "LIT007": { "limit": 0 @@ -27,9 +27,9 @@ "limit": 0 }, "LIT010": { - "limit": 16692 + "limit": 16669 }, "LIT011": { - "limit": 5594 + "limit": 5592 } }