Skip to content

Commit 99e1eaa

Browse files
authored
Merge pull request #38205 from BerriAI/litellm_decrease_anys_opus5_round2
refactor(repositories): type prisma table access with one generic protocol
2 parents 434add7 + 7965cfd commit 99e1eaa

103 files changed

Lines changed: 2314 additions & 1319 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

basedpyright-code-budget.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"reportAny": {
3-
"limit": 19949
3+
"limit": 18505
44
},
55
"reportArgumentType": {
6-
"limit": 2566
6+
"limit": 2564
77
},
88
"reportAssignmentType": {
99
"limit": 320
1010
},
1111
"reportAttributeAccessIssue": {
12-
"limit": 488
12+
"limit": 483
1313
},
1414
"reportCallIssue": {
15-
"limit": 114
15+
"limit": 113
1616
},
1717
"reportConstantRedefinition": {
1818
"limit": 40
@@ -24,7 +24,7 @@
2424
"limit": 19
2525
},
2626
"reportExplicitAny": {
27-
"limit": 6049
27+
"limit": 5976
2828
},
2929
"reportFunctionMemberAccess": {
3030
"limit": 7
@@ -45,7 +45,7 @@
4545
"limit": 35
4646
},
4747
"reportInvalidTypeForm": {
48-
"limit": 35
48+
"limit": 34
4949
},
5050
"reportInvalidTypeVarUse": {
5151
"limit": 2
@@ -54,10 +54,10 @@
5454
"limit": 0
5555
},
5656
"reportMissingParameterType": {
57-
"limit": 5661
57+
"limit": 5659
5858
},
5959
"reportMissingTypeArgument": {
60-
"limit": 15555
60+
"limit": 15504
6161
},
6262
"reportMissingTypeStubs": {
6363
"limit": 40
@@ -72,7 +72,7 @@
7272
"limit": 0
7373
},
7474
"reportOptionalMemberAccess": {
75-
"limit": 1061
75+
"limit": 1058
7676
},
7777
"reportOptionalOperand": {
7878
"limit": 0
@@ -99,31 +99,31 @@
9999
"limit": 0
100100
},
101101
"reportUnknownArgumentType": {
102-
"limit": 44655
102+
"limit": 44530
103103
},
104104
"reportUnknownLambdaType": {
105105
"limit": 109
106106
},
107107
"reportUnknownMemberType": {
108-
"limit": 39009
108+
"limit": 38828
109109
},
110110
"reportUnknownParameterType": {
111-
"limit": 19883
111+
"limit": 19847
112112
},
113113
"reportUnknownVariableType": {
114-
"limit": 30569
114+
"limit": 30386
115115
},
116116
"reportUnnecessaryCast": {
117117
"limit": 117
118118
},
119119
"reportUnnecessaryComparison": {
120-
"limit": 699
120+
"limit": 697
121121
},
122122
"reportUnnecessaryContains": {
123123
"limit": 5
124124
},
125125
"reportUnnecessaryIsInstance": {
126-
"limit": 836
126+
"limit": 833
127127
},
128128
"reportUntypedBaseClass": {
129129
"limit": 0

enterprise/litellm_enterprise/proxy/common_utils/check_batch_cost.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
)
1515

1616
if TYPE_CHECKING:
17+
from prisma import models as prisma_models
18+
1719
from litellm.integrations.prometheus import PrometheusLogger
1820
from litellm.proxy._types import LiteLLM_ManagedObjectTable
1921
from litellm.proxy.utils import PrismaClient, ProxyLogging
@@ -351,7 +353,7 @@ def _is_output_file_gone_at_provider(error: Exception, output_file_id: Optional[
351353
return isinstance(error, (NotFoundError, openai.NotFoundError)) and output_file_id in str(error)
352354

353355
async def _finalize_unbilled_terminal_job(
354-
self, job: "LiteLLM_ManagedObjectTable", response: "LiteLLMBatch"
356+
self, job: "prisma_models.LiteLLM_ManagedObjectTable", response: "LiteLLMBatch"
355357
) -> None:
356358
"""Persist a terminal batch that has nothing billable, converting any raw
357359
provider file ids to managed ids, and take it out of the poll page."""

litellm/integrations/prometheus.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ async def count(self) -> int: ...
9696

9797
def _paginated_table(repository: BaseRepository[_TableRowT]) -> _PaginatedPrismaTable[_TableRowT]:
9898
"""View a repository's prisma table through the pagination surface budget metrics need."""
99-
return repository.table
99+
return cast(
100+
_PaginatedPrismaTable[_TableRowT],
101+
repository.table, # cast-ok: prisma rows carry the budget columns the domain model declares
102+
)
100103

101104

102105
class _OrgBudgetRow(Protocol):

litellm/models/team.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class TeamBase(LiteLLMPydanticObjectBase):
6464
team_alias: str | None = None
6565
team_id: str | None = None
6666
organization_id: str | None = None
67-
admins: list = []
68-
members: list = []
67+
admins: list[str] = []
68+
members: list[str] = []
6969
members_with_roles: list[Member] = []
7070
team_member_permissions: list[str] | None = None
7171
metadata: dict | None = None
@@ -75,7 +75,7 @@ class TeamBase(LiteLLMPydanticObjectBase):
7575
soft_budget: float | None = None
7676
budget_duration: str | None = None
7777
budget_limits: list[BudgetLimitEntry] | None = None
78-
models: list = []
78+
models: list[str] = []
7979
blocked: bool = False
8080
router_settings: dict | None = None
8181
access_group_ids: list[str] | None = None

0 commit comments

Comments
 (0)