@@ -1659,6 +1659,32 @@ def operation() -> str:
16591659 assert attempts ["count" ] == 3
16601660
16611661
1662+ def test_retry_operation_handles_integer_subclass_status_codes_as_retryable_unknown ():
1663+ class _StatusCodeInt (int ):
1664+ pass
1665+
1666+ attempts = {"count" : 0 }
1667+
1668+ def operation () -> str :
1669+ attempts ["count" ] += 1
1670+ if attempts ["count" ] < 3 :
1671+ raise HyperbrowserError (
1672+ "int-subclass status code" ,
1673+ status_code = _StatusCodeInt (429 ), # type: ignore[arg-type]
1674+ )
1675+ return "ok"
1676+
1677+ result = retry_operation (
1678+ operation_name = "sync retry int-subclass status code" ,
1679+ operation = operation ,
1680+ max_attempts = 5 ,
1681+ retry_delay_seconds = 0.0001 ,
1682+ )
1683+
1684+ assert result == "ok"
1685+ assert attempts ["count" ] == 3
1686+
1687+
16621688def test_retry_operation_handles_signed_string_status_codes_as_retryable_unknown ():
16631689 attempts = {"count" : 0 }
16641690
@@ -2472,6 +2498,35 @@ async def operation() -> str:
24722498 asyncio .run (run ())
24732499
24742500
2501+ def test_retry_operation_async_handles_integer_subclass_status_codes_as_retryable_unknown ():
2502+ class _StatusCodeInt (int ):
2503+ pass
2504+
2505+ async def run () -> None :
2506+ attempts = {"count" : 0 }
2507+
2508+ async def operation () -> str :
2509+ attempts ["count" ] += 1
2510+ if attempts ["count" ] < 3 :
2511+ raise HyperbrowserError (
2512+ "int-subclass status code" ,
2513+ status_code = _StatusCodeInt (429 ), # type: ignore[arg-type]
2514+ )
2515+ return "ok"
2516+
2517+ result = await retry_operation_async (
2518+ operation_name = "async retry int-subclass status code" ,
2519+ operation = operation ,
2520+ max_attempts = 5 ,
2521+ retry_delay_seconds = 0.0001 ,
2522+ )
2523+
2524+ assert result == "ok"
2525+ assert attempts ["count" ] == 3
2526+
2527+ asyncio .run (run ())
2528+
2529+
24752530def test_retry_operation_async_retries_bytearray_rate_limit_errors ():
24762531 async def run () -> None :
24772532 attempts = {"count" : 0 }
0 commit comments