Skip to content

Commit

Permalink
Merge branch 'aioretryproto-doc'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anvil committed Dec 16, 2023
2 parents f8a62c6 + 796ae4c commit 4d7559b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### New

### Changes
* update AioretryProtocol documentation

### Fixes

Expand Down
7 changes: 7 additions & 0 deletions docs/source/kaioretry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ The :py:class:`kaioretry.Context` class

.. automodule:: kaioretry.context
:members:


Misc Types
----------

.. automodule:: kaioretry.types
:members:
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.
"""
...
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ pytest-cov = ">=4"
optional = true

[tool.poetry.group.sphinx.dependencies]
sphinx = ">=5"
sphinx = ">=7"
sphinx-autodoc-typehints = ">=1.17"
sphinx-rtd-theme = "*"
sphinx-rtd-theme = ">=2"

[build-system]
requires = ["poetry-core>=1.4.0"]
Expand Down

0 comments on commit 4d7559b

Please sign in to comment.