From 8655283659f1113b6ca9093fdb32fc31487f9f76 Mon Sep 17 00:00:00 2001 From: derhornspieler <15236687+derhornspieler@users.noreply.github.com> Date: Sun, 23 Aug 2026 17:51:12 -0400 Subject: [PATCH] fix(anthropic): stop annotating loop-assigned locals as Final The recursion-to-loop rewrite carried its Final annotations onto locals that are now assigned once per iteration, which basedpyright reports as an error: a Final cannot be assigned within a loop. Each is a genuine per-iteration rebind, so they carry rebind-ok with the reason instead --- litellm/llms/anthropic/common_utils.py | 2 +- litellm/llms/anthropic/wif.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py index cb50df64301..36372e7b4e5 100644 --- a/litellm/llms/anthropic/common_utils.py +++ b/litellm/llms/anthropic/common_utils.py @@ -189,7 +189,7 @@ def _fetch_anthropic_model_ids( collected: tuple[str, ...] = () # rebind-ok: accumulates one page of ids per iteration cursor: str | None = after_id # rebind-ok: advances to each page's last_id for _ in range(max(pages_left, 0)): - page: Final = _fetch_anthropic_models_page(api_base, headers, cursor) + page = _fetch_anthropic_models_page(api_base, headers, cursor) # rebind-ok: one page per iteration collected += tuple(entry.id for entry in page.data) if not page.has_more or page.last_id is None: return collected diff --git a/litellm/llms/anthropic/wif.py b/litellm/llms/anthropic/wif.py index 4be1a1e7ae1..7900bcebcd7 100644 --- a/litellm/llms/anthropic/wif.py +++ b/litellm/llms/anthropic/wif.py @@ -278,7 +278,7 @@ def _strip_path_suffixes(path: str) -> str: token URL. Each pass removes at most one suffix, so the loop is bounded by the segment count.""" trimmed = path.rstrip("/") # rebind-ok: fixed-point strip, one suffix per pass while True: - shortened: Final = next( + shortened = next( # rebind-ok: one suffix removed per iteration (trimmed.removesuffix(suffix) for suffix in _CHAT_BASE_SUFFIXES if trimmed.endswith(suffix)), trimmed, )