The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(auth): put TQ008 suppressions on the patch call lines
Shivi Jainabaa2f8b81c4
diff --git a/tests/test_litellm/proxy/auth/test_auth_checks.py b/tests/test_litellm/proxy/auth/test_auth_checks.pyindex 4fdb49e47ef..29f6c3861f6 100644--- a/tests/test_litellm/proxy/auth/test_auth_checks.py+++ b/tests/test_litellm/proxy/auth/test_auth_checks.py@@ -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.0with (- 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(diff --git a/tests/test_litellm/proxy/auth/test_model_access_group_budgets.py b/tests/test_litellm/proxy/auth/test_model_access_group_budgets.pyindex a4206a0ac92..7506bd031d9 100644--- a/tests/test_litellm/proxy/auth/test_model_access_group_budgets.py+++ b/tests/test_litellm/proxy/auth/test_model_access_group_budgets.py@@ -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": []},