From f3d1909528b9ee95c79c556cc3380c248bffe49f Mon Sep 17 00:00:00 2001 From: Andy Freeland Date: Tue, 14 Nov 2023 21:37:42 +0900 Subject: [PATCH] Add `RetryCallState` to the API docs (#419) * Add `RetryCallState` to the API docs User code can access the `RetryCallState` so its members should be documented. * :noindex: `tenacity.RetryCallState` in the README * Move `RetryCallState` docs to the API docs where hopefully they render on RTD --- doc/source/api.rst | 3 +++ doc/source/index.rst | 50 +++++++------------------------------------- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/doc/source/api.rst b/doc/source/api.rst index 1cf7dc75..7a80c4e7 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -17,6 +17,9 @@ Retry Main API .. autoclass:: tenacity.tornadoweb.TornadoRetrying :members: +.. autoclass:: tenacity.RetryCallState + :members: + After Functions --------------- diff --git a/doc/source/index.rst b/doc/source/index.rst index ce586f9e..804e6074 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -402,43 +402,7 @@ without raising an exception (or you can re-raise or do anything really) RetryCallState ~~~~~~~~~~~~~~ -``retry_state`` argument is an object of `RetryCallState` class: - -.. autoclass:: tenacity.RetryCallState - - Constant attributes: - - .. autoattribute:: start_time(float) - :annotation: - - .. autoattribute:: retry_object(BaseRetrying) - :annotation: - - .. autoattribute:: fn(callable) - :annotation: - - .. autoattribute:: args(tuple) - :annotation: - - .. autoattribute:: kwargs(dict) - :annotation: - - Variable attributes: - - .. autoattribute:: attempt_number(int) - :annotation: - - .. autoattribute:: outcome(tenacity.Future or None) - :annotation: - - .. autoattribute:: outcome_timestamp(float or None) - :annotation: - - .. autoattribute:: idle_for(float) - :annotation: - - .. autoattribute:: next_action(tenacity.RetryAction or None) - :annotation: +``retry_state`` argument is an object of :class:`~tenacity.RetryCallState` class. Other Custom Callbacks ~~~~~~~~~~~~~~~~~~~~~~ @@ -447,33 +411,33 @@ It's also possible to define custom callbacks for other keyword arguments. .. function:: my_stop(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation :return: whether or not retrying should stop :rtype: bool .. function:: my_wait(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation :return: number of seconds to wait before next retry :rtype: float .. function:: my_retry(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation :return: whether or not retrying should continue :rtype: bool .. function:: my_before(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation .. function:: my_after(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation .. function:: my_before_sleep(retry_state) - :param RetryState retry_state: info about current retry invocation + :param RetryCallState retry_state: info about current retry invocation Here's an example with a custom ``before_sleep`` function: