(*dargs: t.Any, **dkw: t.Any)
Wrap a function with a new `Retrying` object.

    :param dargs: positional arguments passed to Retrying object
    :param dkw: keyword arguments passed to the Retrying object
Wrap a function with a new `Retrying` object.
Wrap a function with a new Retrying object .
def retry(*dargs: t.Any, **dkw: t.Any) -> t.Union[WrappedFn, t.Callable[[WrappedFn], WrappedFn]]:  # noqa
    """Wrap a function with a new `Retrying` object.

    :param dargs: positional arguments passed to Retrying object
    :param dkw: keyword arguments passed to the Retrying object
    """
    # support both @retry and @retry() as valid syntax
    if len(dargs) == 1 and callable(dargs[0]):
        return retry()(dargs[0])
    else:

        def wrap(f: WrappedFn) -> WrappedFn:
            if isinstance(f, retry_base):
                warnings.warn(
                    f"Got retry_base instance ({f.__class__.__name__}) as callable argument, "
                    f"this will probably hang indefinitely (did you mean retry={f.__class__.__name__}(...)?)"
                )
            if iscoroutinefunction(f):
                r: "BaseRetrying" = AsyncRetrying(*dargs, **dkw)
            elif tornado and hasattr(tornado.gen, "is_coroutine_function") and tornado.gen.is_coroutine_function(f):
                r = TornadoRetrying(*dargs, **dkw)
            else:
                r = Retrying(*dargs, **dkw)

            return r.wraps(f)

        return wrap
def retry ( * dargs : t . Any , * * dkw : t . Any ) -> t . Union [ WrappedFn , t . Callable [ [ WrappedFn ] , WrappedFn ] ] : # noqa # support both @retry and @retry() as valid syntax if len ( dargs ) == 1 and callable ( dargs [ 0 ] ) : return retry ( ) ( dargs [ 0 ] ) else : def wrap ( f : WrappedFn ) -> WrappedFn : if isinstance ( f , retry_base ) : warnings . warn ( f"Got retry_base instance ({f.__class__.__name__}) as callable argument, " f"this will probably hang indefinitely (did you mean retry={f.__class__.__name__}(...)?)" ) if iscoroutinefunction ( f ) : r : "BaseRetrying" = AsyncRetrying ( * dargs , * * dkw ) elif tornado and hasattr ( tornado . gen , "is_coroutine_function" ) and tornado . gen . is_coroutine_function ( f ) : r = TornadoRetrying ( * dargs , * * dkw ) else : r = Retrying ( * dargs , * * dkw ) return r . wraps ( f ) return wrap