From 8795ac838d3ce8e8d069687c2d10ea1661a57bbb Mon Sep 17 00:00:00 2001 From: Nathan Price Date: Wed, 17 Jun 2026 07:52:41 -0500 Subject: [PATCH] style(router): modernize new annotations to satisfy strict-rule budget Use PEP 585/604 forms (list/dict, X | None) for the ttft_timeout/stream_idle_timeout annotations added by this PR so UP006/UP045 totals stay within the strict-rule budget ceiling the base enforces. --- litellm/router.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/litellm/router.py b/litellm/router.py index d07c2fe460e..6bf2733fdc6 100644 --- a/litellm/router.py +++ b/litellm/router.py @@ -274,8 +274,8 @@ class Router: ] = None, # max fallbacks to try before exiting the call. Defaults to 5. timeout: Optional[float] = None, stream_timeout: Optional[float] = None, - ttft_timeout: Optional[float] = None, - stream_idle_timeout: Optional[float] = None, + ttft_timeout: float | None = None, + stream_idle_timeout: float | None = None, default_litellm_params: Optional[ dict ] = None, # default params for Router.chat.completion.create @@ -2894,13 +2894,13 @@ class Router: async def _collect_stream_with_ttft_timeout( self, response: CustomStreamWrapper, - messages: List[Dict[str, str]], - ttft_timeout: Optional[float], - stream_idle_timeout: Optional[float] = None, + messages: list[dict[str, str]], + ttft_timeout: float | None, + stream_idle_timeout: float | None = None, ) -> ModelResponse: from litellm.main import stream_chunk_builder - chunks: List = [] + chunks: list = [] aiter = response.__aiter__() try: @@ -3452,7 +3452,7 @@ class Router: ) return timeout - def _get_ttft_timeout(self, kwargs: dict, data: dict) -> Optional[float]: + def _get_ttft_timeout(self, kwargs: dict, data: dict) -> float | None: for source in ( kwargs.get("ttft_timeout"), data.get("ttft_timeout"), @@ -3463,7 +3463,7 @@ class Router: return source return None - def _get_stream_idle_timeout(self, kwargs: dict, data: dict) -> Optional[float]: + def _get_stream_idle_timeout(self, kwargs: dict, data: dict) -> float | None: for source in ( kwargs.get("stream_idle_timeout"), data.get("stream_idle_timeout"),