mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(typing): keep optional find_many arguments out of prisma calls
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
ce13ffa469
commit
82a7b9e835
5 changed files with 37 additions and 25 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue