mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
fix(auth): put TQ008 suppressions on the patch call lines
The test-quality gate attributes the comment to the `patch(` line, so reasons on the closing paren did not count and lint failed after format started passing. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
53ba8b9866
commit
abaa2f8b81
2 changed files with 30 additions and 20 deletions
|
|
@ -5527,9 +5527,9 @@ async def _run_internal_user_budget_alert(
|
|||
|
||||
with (
|
||||
patch("litellm.proxy.proxy_server.prisma_client", None), # test-quality-ok: common_checks has no database seam
|
||||
patch(
|
||||
patch( # test-quality-ok: common_checks imports get_current_spend locally
|
||||
"litellm.proxy.proxy_server.get_current_spend", _get_spend
|
||||
), # test-quality-ok: common_checks imports it locally
|
||||
),
|
||||
patch.object(slack_alerting, "send_alert", send_alert),
|
||||
):
|
||||
error: Final = await _check_for_error()
|
||||
|
|
@ -6554,14 +6554,20 @@ async def test_common_checks_calls_get_team_membership_once_per_request():
|
|||
membership.spend = 0.0
|
||||
|
||||
with (
|
||||
patch("litellm.proxy.proxy_server.prisma_client", MagicMock()),
|
||||
patch("litellm.proxy.proxy_server.user_api_key_cache", UserApiKeyCache()),
|
||||
patch(
|
||||
patch( # test-quality-ok: common_checks imports prisma_client from proxy_server
|
||||
"litellm.proxy.proxy_server.prisma_client", MagicMock()
|
||||
),
|
||||
patch( # test-quality-ok: common_checks imports user_api_key_cache from proxy_server
|
||||
"litellm.proxy.proxy_server.user_api_key_cache", UserApiKeyCache()
|
||||
),
|
||||
patch( # test-quality-ok: counts membership loads; common_checks has no membership seam
|
||||
"litellm.proxy.auth.auth_checks.get_team_membership",
|
||||
new_callable=AsyncMock,
|
||||
return_value=membership,
|
||||
) as load_membership,
|
||||
patch("litellm.proxy.proxy_server.get_current_spend", new_callable=AsyncMock, return_value=0.0),
|
||||
patch( # test-quality-ok: common_checks imports get_current_spend locally
|
||||
"litellm.proxy.proxy_server.get_current_spend", new_callable=AsyncMock, return_value=0.0
|
||||
),
|
||||
):
|
||||
result = await common_checks(
|
||||
request_body={"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "hi"}]},
|
||||
|
|
@ -6640,14 +6646,20 @@ async def test_common_checks_does_not_skip_member_limits_when_membership_lookup_
|
|||
)
|
||||
|
||||
with (
|
||||
patch("litellm.proxy.proxy_server.prisma_client", MagicMock()),
|
||||
patch("litellm.proxy.proxy_server.user_api_key_cache", UserApiKeyCache()),
|
||||
patch(
|
||||
patch( # test-quality-ok: common_checks imports prisma_client from proxy_server
|
||||
"litellm.proxy.proxy_server.prisma_client", MagicMock()
|
||||
),
|
||||
patch( # test-quality-ok: common_checks imports user_api_key_cache from proxy_server
|
||||
"litellm.proxy.proxy_server.user_api_key_cache", UserApiKeyCache()
|
||||
),
|
||||
patch( # test-quality-ok: injects membership lookup failure; common_checks has no seam
|
||||
"litellm.proxy.auth.auth_checks.get_team_membership",
|
||||
new_callable=AsyncMock,
|
||||
side_effect=lookup_error,
|
||||
),
|
||||
patch("litellm.proxy.proxy_server.get_current_spend", new_callable=AsyncMock, return_value=0.0),
|
||||
patch( # test-quality-ok: common_checks imports get_current_spend locally
|
||||
"litellm.proxy.proxy_server.get_current_spend", new_callable=AsyncMock, return_value=0.0
|
||||
),
|
||||
):
|
||||
with pytest.raises(HTTPException) as exc:
|
||||
await common_checks(
|
||||
|
|
|
|||
|
|
@ -349,9 +349,9 @@ async def _enforce(
|
|||
read, seen = _spend_reader(spend_by_counter_key or {})
|
||||
# The check takes its client and cache as arguments, injected just below. get_current_spend is the
|
||||
# one collaborator it reaches by a lazy `from litellm.proxy.proxy_server import`, with no parameter.
|
||||
with patch(
|
||||
with patch( # test-quality-ok: get_current_spend is lazily imported inside the budget check
|
||||
"litellm.proxy.proxy_server.get_current_spend", read
|
||||
): # test-quality-ok: get_current_spend is lazily imported inside _model_access_group_max_budget_check and has no injection point
|
||||
):
|
||||
await _model_access_group_max_budget_check(
|
||||
matched_model_access_groups=matched,
|
||||
prisma_client=prisma_client if prisma_client is not None else _RecordingPrismaClient(*rows),
|
||||
|
|
@ -511,17 +511,15 @@ async def _common_checks_with_over_budget_group(*, skip_budget_checks: bool) ->
|
|||
read, _ = _spend_reader({MODEL_ACCESS_GROUP_COUNTER_KEY: 99.0})
|
||||
|
||||
with (
|
||||
# common_checks resolves all three off the proxy_server module at call time; its signature
|
||||
# has no client, cache or spend-reader parameter to pass them through instead.
|
||||
patch(
|
||||
patch( # test-quality-ok: common_checks lazily imports prisma_client from proxy_server
|
||||
"litellm.proxy.proxy_server.prisma_client", prisma_client
|
||||
), # test-quality-ok: common_checks lazily imports prisma_client from proxy_server and takes no client parameter
|
||||
patch(
|
||||
),
|
||||
patch( # test-quality-ok: common_checks lazily imports user_api_key_cache from proxy_server
|
||||
"litellm.proxy.proxy_server.user_api_key_cache", cache
|
||||
), # test-quality-ok: common_checks lazily imports user_api_key_cache from proxy_server and takes no cache parameter
|
||||
patch(
|
||||
),
|
||||
patch( # test-quality-ok: get_current_spend is lazily imported inside the budget check
|
||||
"litellm.proxy.proxy_server.get_current_spend", read
|
||||
), # test-quality-ok: get_current_spend is lazily imported inside the budget check and has no injection point
|
||||
),
|
||||
):
|
||||
return await common_checks(
|
||||
request_body={"model": "gpt-4o", "messages": []},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue