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
This commit is contained in:
derhornspieler 2026-08-23 17:51:12 -04:00
parent e71d5cf8fe
commit 8655283659
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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,
)