From 13074e8f5d4daf0a71fa8e4560485999cd5a4197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damien=20Nad=C3=A9?= Date: Thu, 1 Jun 2023 00:11:09 +0200 Subject: [PATCH] add aioretry typing tests cases with an *args signature --- test/static_analysis/41_aioretry_args.py | 23 +++++++++++++++++ .../42_aioretry_args_explicit_decorate.py | 25 +++++++++++++++++++ test/static_analysis/43_aioretry_params.py | 23 +++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 test/static_analysis/41_aioretry_args.py create mode 100644 test/static_analysis/42_aioretry_args_explicit_decorate.py create mode 100644 test/static_analysis/43_aioretry_params.py diff --git a/test/static_analysis/41_aioretry_args.py b/test/static_analysis/41_aioretry_args.py new file mode 100644 index 0000000..6b561aa --- /dev/null +++ b/test/static_analysis/41_aioretry_args.py @@ -0,0 +1,23 @@ + +from __future__ import annotations + +from typing import reveal_type, Any + +from kaioretry import Retry, Context + + +aioretry = Retry( + exceptions=(ValueError, NotImplementedError), + context=Context(tries=5, delay=2)).aioretry + + +@aioretry +async def request(*args: Any) -> str: + """Request server something""" + return "asdf" +reveal_type(request) + +async def get_obj(obj_id: str) -> int: + """obtain an objet through https request""" + response = await request(1, 2, 3) + return int(response) diff --git a/test/static_analysis/42_aioretry_args_explicit_decorate.py b/test/static_analysis/42_aioretry_args_explicit_decorate.py new file mode 100644 index 0000000..6bcbd6c --- /dev/null +++ b/test/static_analysis/42_aioretry_args_explicit_decorate.py @@ -0,0 +1,25 @@ + +from __future__ import annotations + +from typing import reveal_type, Any + +from kaioretry import Retry, Context + + +aioretry = Retry( + exceptions=(ValueError, NotImplementedError), + context=Context(tries=5, delay=2)).aioretry + + +async def request(*args: Any) -> str: + """Request server something""" + return "asdf" + +request = aioretry(request) + + + +async def get_obj(obj_id: str) -> int: + """obtain an objet through https request""" + response = await request(1, 2, 3) + return int(response) diff --git a/test/static_analysis/43_aioretry_params.py b/test/static_analysis/43_aioretry_params.py new file mode 100644 index 0000000..b1498ab --- /dev/null +++ b/test/static_analysis/43_aioretry_params.py @@ -0,0 +1,23 @@ + +from __future__ import annotations + +from typing import reveal_type, Any + +from kaioretry import Retry, Context + + +aioretry = Retry( + exceptions=(ValueError, NotImplementedError), + context=Context(tries=5, delay=2)).aioretry + + +@aioretry +async def request(i: int, j: int, k: int) -> str: + """Request server something""" + return "asdf" + + +async def get_obj(obj_id: str) -> int: + """obtain an objet through https request""" + response = await request(1, 2, 3) + return int(response)