From a02e2fc87b243c8eabe38dac533be615a4a8f245 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 --- .../41_aioretry_untyped_args.py | 23 +++++++++++++++++ .../static_analysis/42_aioretry_typed_args.py | 23 +++++++++++++++++ .../43_aioretry_args_explicit_decorate.py | 25 +++++++++++++++++++ test/static_analysis/44_aioretry_params.py | 23 +++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 test/static_analysis/41_aioretry_untyped_args.py create mode 100644 test/static_analysis/42_aioretry_typed_args.py create mode 100644 test/static_analysis/43_aioretry_args_explicit_decorate.py create mode 100644 test/static_analysis/44_aioretry_params.py diff --git a/test/static_analysis/41_aioretry_untyped_args.py b/test/static_analysis/41_aioretry_untyped_args.py new file mode 100644 index 0000000..6b561aa --- /dev/null +++ b/test/static_analysis/41_aioretry_untyped_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_typed_args.py b/test/static_analysis/42_aioretry_typed_args.py new file mode 100644 index 0000000..67b343f --- /dev/null +++ b/test/static_analysis/42_aioretry_typed_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: int) -> 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/43_aioretry_args_explicit_decorate.py b/test/static_analysis/43_aioretry_args_explicit_decorate.py new file mode 100644 index 0000000..6bcbd6c --- /dev/null +++ b/test/static_analysis/43_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/44_aioretry_params.py b/test/static_analysis/44_aioretry_params.py new file mode 100644 index 0000000..b1498ab --- /dev/null +++ b/test/static_analysis/44_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)