Skip to content

Commit

Permalink
add real docstring to AioretryProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
Anvil committed Dec 16, 2023
1 parent 0e739a4 commit dbedd5d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions kaioretry/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Custom types used by kaioretry"""
"""
Kaioretry defines a bunch
"""


from typing import TypeAlias, TypeVar, ParamSpec, Any, overload
Expand Down Expand Up @@ -30,6 +32,7 @@


FuncParam = ParamSpec('FuncParam')

FuncRetVal = TypeVar('FuncRetVal')

Function: TypeAlias = Callable[..., Any]
Expand All @@ -47,7 +50,11 @@

class AioretryProtocol(Protocol):

"""The type of the main aioretry decorator"""
"""The :py:class:`typing.Protocol` describing the behaviour of the
:py:func:`~kaioretry.aioretry` decorator.
.. automethod:: __call__
"""

@overload
def __call__(self, func: AwaitableFunc[FuncParam, FuncRetVal]) \
Expand All @@ -61,4 +68,14 @@ def __call__(self, func: Callable[FuncParam, FuncRetVal]) \

def __call__(self, func: AnyFunction[FuncParam, FuncRetVal]) \
-> AioretryCoro[FuncParam, FuncRetVal]:
"""When called (to decorate a function), an aioretry decorator will...
:param func: ... take a function as input...
:returns: and, if ``func`` returns an
:py:class:`~collections.abc.Awaitable`, then return a same-signature
same-type coroutine function. If ``func`` does not, then return a
same-signature *coroutine* function that, once awaited, return
``func`` original return value.
"""
...

0 comments on commit dbedd5d

Please sign in to comment.