@@ -52,9 +52,7 @@ async def retry_target_generator(
52
52
timeout : Optional [float ] = None ,
53
53
on_error : Optional [Callable [[Exception ], None ]] = None ,
54
54
exception_factory : Optional [
55
- Callable [
56
- [List [Exception ], bool , float ], Tuple [Exception , Optional [Exception ]]
57
- ]
55
+ Callable [[List [Exception ], bool , float ], Tuple [Exception , Optional [Exception ]]]
58
56
] = None ,
59
57
** kwargs ,
60
58
) -> AsyncGenerator [T , None ]:
@@ -126,7 +124,7 @@ def on_error(e):
126
124
filter_retry_wrapped = retryable_with_filter(target)
127
125
```
128
126
"""
129
- subgenerator : Optional [AsyncIterator [T ]] = None
127
+ subgenerator : Optional [AsyncIterator [T ]] = None
130
128
timeout = kwargs .get ("deadline" , timeout )
131
129
deadline : Optional [float ] = time .monotonic () + timeout if timeout else None
132
130
# keep track of retryable exceptions we encounter to pass in to exception_factory
@@ -140,9 +138,11 @@ def on_error(e):
140
138
# Start a new retry loop
141
139
try :
142
140
# generator may be raw iterator, or wrapped in an awaitable
143
- gen_instance : Union [AsyncIterable [T ], Awaitable [AsyncIterable [T ]]] = target ()
141
+ gen_instance : Union [
142
+ AsyncIterable [T ], Awaitable [AsyncIterable [T ]]
143
+ ] = target ()
144
144
try :
145
- gen_instance = await gen_instance # type: ignore
145
+ gen_instance = await gen_instance # type: ignore
146
146
except TypeError :
147
147
# was not awaitable
148
148
pass
@@ -156,7 +156,7 @@ def on_error(e):
156
156
while True :
157
157
## Read from Subgenerator
158
158
if supports_send :
159
- next_value = await subgenerator .asend (sent_in ) # type: ignore
159
+ next_value = await subgenerator .asend (sent_in ) # type: ignore
160
160
else :
161
161
next_value = await subgenerator .__anext__ ()
162
162
## Yield from Wrapper to caller
@@ -175,7 +175,9 @@ def on_error(e):
175
175
# bare except catches any exception passed to `athrow`
176
176
# delegate error handling to subgenerator
177
177
if getattr (subgenerator , "athrow" , None ):
178
- await cast (AsyncGenerator [T , None ], subgenerator ).athrow (* sys .exc_info ())
178
+ await cast (AsyncGenerator [T , None ], subgenerator ).athrow (
179
+ * sys .exc_info ()
180
+ )
179
181
else :
180
182
raise
181
183
return
0 commit comments