Skip to content

Commit 3e1d8b4

Browse files
authored
refactor: Remove the unused retry classification helper (#1021)
`_utils/errors.py::is_retryable_error` is a stale copy of `http_clients/_impit.py::_is_retryable_error`. No production code calls it — only its own tests did — and it sits in a private module, so nothing depends on it. Once #1019 narrows the real policy, keeping a second copy that still claims every `impit.HTTPError` is transient is actively misleading. Removes the function, its two test cases, and the imports they alone needed. Split out of #1006. *✍️ Drafted by Claude Code*
1 parent 334e131 commit 3e1d8b4

2 files changed

Lines changed: 3 additions & 52 deletions

File tree

‎src/apify_client/_utils/errors.py‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
from typing import TYPE_CHECKING
44

5-
import impit
6-
7-
from apify_client.errors import InvalidResponseBodyError, NotFoundError
5+
from apify_client.errors import NotFoundError
86

97
if TYPE_CHECKING:
108
from apify_client.errors import ApifyApiError
@@ -33,19 +31,3 @@ def catch_not_found_for_resource_or_throw(exc: ApifyApiError, resource_id: str |
3331
if resource_id is None:
3432
raise exc
3533
catch_not_found_or_throw(exc)
36-
37-
38-
def is_retryable_error(exc: Exception) -> bool:
39-
"""Check if the given error is retryable.
40-
41-
All `impit.HTTPError` subclasses are considered retryable because they represent transport-level failures
42-
(network issues, timeouts, protocol errors, body decoding errors) that are typically transient. HTTP status
43-
code errors are handled separately in `_make_request` based on the response status code, not here.
44-
"""
45-
return isinstance(
46-
exc,
47-
(
48-
InvalidResponseBodyError,
49-
impit.HTTPError,
50-
),
51-
)

‎tests/unit/test_utils.py‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@
1111
from typing import TYPE_CHECKING, Any
1212
from unittest.mock import Mock
1313

14-
import impit
1514
import pytest
1615

1716
from apify_client._models import WebhookCondition, WebhookCreate
1817
from apify_client._resource_clients._resource_client import ResourceClientBase
1918
from apify_client._utils.crypto import create_hmac_signature, create_storage_content_signature, encode_base62
2019
from apify_client._utils.encoding import encode_key_value_store_record_value, encode_webhooks_to_base64
21-
from apify_client._utils.errors import catch_not_found_or_throw, is_retryable_error
20+
from apify_client._utils.errors import catch_not_found_or_throw
2221
from apify_client._utils.http import (
2322
is_compressible_content_type,
2423
response_to_dict,
2524
response_to_list,
2625
to_safe_id,
2726
)
2827
from apify_client._utils.try_import import FailedImport, try_import
29-
from apify_client.errors import ApifyApiError, InvalidResponseBodyError
28+
from apify_client.errors import ApifyApiError
3029

3130
if TYPE_CHECKING:
3231
from apify_client._typeddicts import WebhookRepresentationDict
@@ -187,36 +186,6 @@ def test_encode_webhooks_to_base64_from_dicts() -> None:
187186
assert result == result_from_models
188187

189188

190-
@pytest.mark.parametrize(
191-
'exc',
192-
[
193-
InvalidResponseBodyError(impit.Response(status_code=200)),
194-
impit.HTTPError('generic http error'),
195-
impit.NetworkError('network error'),
196-
impit.TimeoutException('timeout'),
197-
impit.RemoteProtocolError('remote protocol error'),
198-
impit.ReadError('read error'),
199-
impit.ConnectError('connect error'),
200-
impit.WriteError('write error'),
201-
impit.DecodingError('decoding error'),
202-
],
203-
)
204-
def test__is_retryable_error(exc: Exception) -> None:
205-
assert is_retryable_error(exc) is True
206-
207-
208-
@pytest.mark.parametrize(
209-
'exc',
210-
[
211-
Exception('generic exception'),
212-
ValueError('value error'),
213-
RuntimeError('runtime error'),
214-
],
215-
)
216-
def test__is_not_retryable_error(exc: Exception) -> None:
217-
assert is_retryable_error(exc) is False
218-
219-
220189
@pytest.mark.parametrize(
221190
('status_code', 'error_type', 'should_suppress'),
222191
[

0 commit comments

Comments
 (0)