Skip to content

Commit ff9c427

Browse files
committed
refactor(util): improve type annotations in retry clients
Replace object with Any in RetryingClient and AsyncRetryingClient method signatures to allow flexible argument passing, and correct the async sleep callable annotation to Awaitable[None] for accurate type checking.
1 parent 9ec3a6e commit ff9c427

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

impresso/util/retry.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import random
2424
import time
2525
from email.utils import parsedate_to_datetime
26-
from typing import Callable
26+
from typing import Any, Awaitable, Callable
2727

2828
import httpx
2929

@@ -162,14 +162,14 @@ class RetryingClient(httpx.Client):
162162

163163
def __init__(
164164
self,
165-
*args: object,
165+
*args: Any,
166166
sleep: Callable[[float], None] = time.sleep,
167-
**kwargs: object,
167+
**kwargs: Any,
168168
) -> None:
169169
super().__init__(*args, **kwargs)
170170
self._sleep = sleep
171171

172-
def send(self, request: httpx.Request, **kwargs: object) -> httpx.Response:
172+
def send(self, request: httpx.Request, **kwargs: Any) -> httpx.Response:
173173
for attempt in range(1, MAX_ATTEMPTS + 1):
174174
try:
175175
response = super().send(request, **kwargs)
@@ -224,14 +224,14 @@ class AsyncRetryingClient(httpx.AsyncClient):
224224

225225
def __init__(
226226
self,
227-
*args: object,
228-
sleep: Callable[[float], object] = asyncio.sleep,
229-
**kwargs: object,
227+
*args: Any,
228+
sleep: Callable[[float], Awaitable[None]] = asyncio.sleep,
229+
**kwargs: Any,
230230
) -> None:
231231
super().__init__(*args, **kwargs)
232232
self._sleep = sleep
233233

234-
async def send(self, request: httpx.Request, **kwargs: object) -> httpx.Response:
234+
async def send(self, request: httpx.Request, **kwargs: Any) -> httpx.Response:
235235
for attempt in range(1, MAX_ATTEMPTS + 1):
236236
try:
237237
response = await super().send(request, **kwargs)

0 commit comments

Comments
 (0)