codeflash-agent/packages/github-app/github_app/retry.py
Kevin Turcios 2caaf6af7c
Fix CI: mypy errors, ruff formatting, switch to prek (#22)
* Fix mypy errors and apply ruff formatting across packages

Fix ast.FunctionDef calls missing type_params for Python 3.12+,
correct type: ignore error codes in _comparator and _plugin, and
run ruff format on all package source and test files.

* Switch CI to prek for lint/typecheck checks

Use j178/prek-action for consistent lint+typecheck (ruff check,
ruff format, interrogate, mypy) matching local pre-commit config.
Keep test as a separate parallel job for test-env support.
2026-04-15 02:52:47 -05:00

24 lines
620 B
Python

"""Retry predicate for transient HTTP errors."""
from __future__ import annotations
import httpx
def is_retryable(exc: Exception) -> bool:
"""Return True for transient errors worth retrying.
Retries: HTTP 429 (rate limit), 5xx (server errors),
connection errors, timeouts.
Does NOT retry: 4xx client errors (permanent failures).
"""
if isinstance(exc, httpx.HTTPStatusError):
code = exc.response.status_code
return code == 429 or code >= 500
return isinstance(
exc,
(httpx.ConnectError, httpx.TimeoutException),
)
# https://smee.io/ACAUooTvHulETive