Skip to content

Commit

Permalink
Merge branch 'sync-to-async-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anvil committed Dec 10, 2023
2 parents c9c883d + acd55a8 commit 5a4b4de
Show file tree
Hide file tree
Showing 186 changed files with 1,291 additions and 1,104 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
---

### New
* add 115 new working static analysis tests cases

### Changes
* use generated retry decorator test files
* use generated static analysis test files instead of the few manually written
ones. 184/217 of them are currently passing.
* rely on functools.wraps to avoid too much internal code

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(*args: Any) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[VarArg(Any)], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(*args: Any) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[VarArg(Any)], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(*args: int) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[VarArg(int)], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(*args: int) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[VarArg(int)], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(**kwargs: Any) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[KwArg(Any)], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(x=1, y=2)
result = await wrapped(x=1, y=2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(**kwargs: Any) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[KwArg(Any)], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(x=1, y=2)
result = await wrapped(x=1, y=2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(**kwargs: int) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[KwArg(int)], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(x=1, y=2)
result = await wrapped(x=1, y=2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(**kwargs: int) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[KwArg(int)], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(x=1, y=2)
result = await wrapped(x=1, y=2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(x: Any, y: Any) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[Any, Any], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(x: Any, y: Any) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[Any, Any], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(x: int, y: int) -> Any:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[int, int], Awaitable[Any]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@

import asyncio
from typing import Any
from collections.abc import Callable, Awaitable
from mypy_extensions import VarArg, KwArg
from kaioretry import retry, aioretry, Retry, Context

from kaioretry import Retry, Context


aioretry_decorator = Retry(
exceptions=(ValueError, NotImplementedError),
context=Context(tries=5, delay=2)).aioretry

async def func(x: int, y: int) -> str:
''' ... '''
return 'return_value'
func = aioretry_decorator(func)

wrapped: Callable[[int, int], Awaitable[str]] = Retry(exceptions=(ValueError, NotImplementedError), context=Context(tries=5, delay=2)).aioretry(func)


async def use_decoration(parameter: str) -> str:
''' obtain result and use it '''
result = await func(1, 2)
result = await wrapped(1, 2)
assert isinstance(result, str)
return f"parameter is {parameter}. result is {result}"

Expand Down
Loading

0 comments on commit 5a4b4de

Please sign in to comment.