mirror of
https://github.com/codeflash-ai/codeflash-agent.git
synced 2026-05-04 18:25:19 +00:00
* 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.
24 lines
620 B
Python
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
|