From b98195e3a40cfa59842cb1284898a0c1e624848b Mon Sep 17 00:00:00 2001 From: Deepanshu Date: Thu, 27 Aug 2026 07:44:27 -0400 Subject: [PATCH] fix(proxy): use typed Deployment/ModelInfo construction in the new drift regression test LiteLLM_Params and ModelInfo instead of raw dicts, plus assert narrowing on two Router calls that can return None, to satisfy basedpyright's strict Deployment(...) construction path. --- .../hooks/test_model_based_tag_rate_limits_hook.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_litellm/proxy/hooks/test_model_based_tag_rate_limits_hook.py b/tests/test_litellm/proxy/hooks/test_model_based_tag_rate_limits_hook.py index a3c9e80e502..6fcaf865c5d 100644 --- a/tests/test_litellm/proxy/hooks/test_model_based_tag_rate_limits_hook.py +++ b/tests/test_litellm/proxy/hooks/test_model_based_tag_rate_limits_hook.py @@ -33,7 +33,7 @@ from litellm.proxy.hooks.tag_rate_limits_shared import ( BACKGROUND_TASKS as _BACKGROUND_TASKS, CONCURRENCY_MIN_SAFETY_TTL_SECONDS as _CONCURRENCY_MIN_SAFETY_TTL_SECONDS, ) -from litellm.types.router import Deployment, RoutingGroup, TagRateLimitEntry, TagRateLimitScope +from litellm.types.router import Deployment, LiteLLM_Params, ModelInfo, RoutingGroup, TagRateLimitEntry, TagRateLimitScope class TimeController: @@ -1626,6 +1626,7 @@ async def test_log_success_event_uses_admissions_own_candidate_set_when_group_me request_kwargs, model_call_details = _call_context(["end_user_id:u1"]) healthy = router._get_routing_group_deployments(model="my-group", team_id=None) + assert healthy is not None admitted = await limiter.async_filter_deployments( model="my-group", healthy_deployments=healthy, messages=None, request_kwargs=request_kwargs ) @@ -1634,12 +1635,14 @@ async def test_log_success_event_uses_admissions_own_candidate_set_when_group_me "my-group", team_id=None, candidate_model_names=("backend-a", "backend-b") )[0].resolved_group - router.get_routing_group("my-group").models.append("backend-0") + routing_group = router.get_routing_group("my-group") + assert routing_group is not None + routing_group.models.append("backend-0") router.add_deployment( Deployment( model_name="backend-0", - litellm_params={"model": "gpt-4o", "mock_response": "ok"}, # type: ignore - model_info={"id": "dep-0", "tag_rate_limits": token_limits}, + litellm_params=LiteLLM_Params(model="gpt-4o", mock_response="ok"), + model_info=ModelInfo(id="dep-0", tag_rate_limits=token_limits), ) ) serving_deployment_id = "dep-b" if admission_bucket_group == "backend-a" else "dep-a"