@@ -105,6 +105,11 @@ def from_params(
105105 )
106106
107107 def __iter__ (self ) -> _t .Retrying :
108+ if not _CONFIG .is_active :
109+ return _t .Retrying (
110+ reraise = True , stop = _t .stop_after_attempt (1 )
111+ ).__iter__ ()
112+
108113 return _t .Retrying (
109114 before_sleep = _make_before_sleep (
110115 self ._name , _CONFIG .on_retry , self ._args , self ._kw
@@ -115,6 +120,11 @@ def __iter__(self) -> _t.Retrying:
115120 ).__iter__ ()
116121
117122 def __aiter__ (self ) -> _t .AsyncRetrying :
123+ if not _CONFIG .is_active :
124+ return _t .AsyncRetrying (
125+ reraise = True , stop = _t .stop_after_attempt (1 )
126+ ).__aiter__ ()
127+
118128 return _t .AsyncRetrying (
119129 before_sleep = _make_before_sleep (
120130 self ._name , _CONFIG .on_retry , self ._args , self ._kw
@@ -229,9 +239,6 @@ def retry_decorator(wrapped: Callable[P, T]) -> Callable[P, T]:
229239
230240 @wraps (wrapped )
231241 def sync_inner (* args : P .args , ** kw : P .kwargs ) -> T : # type: ignore[return]
232- if not _CONFIG .is_active :
233- return wrapped (* args , ** kw )
234-
235242 for attempt in retry_ctx .with_name ( # noqa: RET503
236243 name , args , kw
237244 ):
@@ -242,9 +249,6 @@ def sync_inner(*args: P.args, **kw: P.kwargs) -> T: # type: ignore[return]
242249
243250 @wraps (wrapped )
244251 async def async_inner (* args : P .args , ** kw : P .kwargs ) -> T : # type: ignore[return]
245- if not _CONFIG .is_active :
246- return await wrapped (* args , ** kw ) # type: ignore[no-any-return,misc]
247-
248252 async for attempt in retry_ctx .with_name ( # noqa: RET503
249253 name , args , kw
250254 ):
0 commit comments