Skip to content

Commit 3672775

Browse files
committed
refactor(import[retry]) Remove unreachable post-loop dead code
why: Every path through the retry loop already returns or raises. The last_exc tracking and post-loop _handle_http_error call were unreachable dead code. what: - Remove last_exc variable declaration and assignment - Remove post-loop _handle_http_error(last_exc) call - Keep minimal fallback raise required by mypy (cannot statically prove range(max_retries + 1) is non-empty)
1 parent ae5b4bd commit 3672775

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

  • src/vcspull/_internal/remotes

src/vcspull/_internal/remotes/base.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ def get(
410410

411411
log.debug("GET %s", url)
412412

413-
last_exc: urllib.error.HTTPError | None = None
414413
for attempt in range(self.max_retries + 1):
415414
try:
416415
with urllib.request.urlopen(request, timeout=self.timeout) as response:
@@ -419,7 +418,6 @@ def get(
419418
return json.loads(body), response_headers
420419
except urllib.error.HTTPError as exc: # noqa: PERF203
421420
if exc.code == 429 and attempt < self.max_retries:
422-
last_exc = exc
423421
delay = self._calculate_retry_delay(exc, attempt)
424422
log.warning(
425423
"Rate limited by %s, retrying in %.1fs (attempt %d/%d)",
@@ -438,11 +436,6 @@ def get(
438436
msg = f"Invalid JSON response from {service_name}"
439437
raise ServiceUnavailableError(msg, service=service_name) from exc
440438

441-
# Retries exhausted on 429 — raise via _handle_http_error
442-
if last_exc is not None:
443-
self._handle_http_error(last_exc, service_name)
444-
445-
# Should never reach here, but for type checker
446439
msg = "Unexpected error"
447440
raise ServiceUnavailableError(msg, service=service_name)
448441

0 commit comments

Comments
 (0)