Skip to content

Commit

Permalink
fix: removed the dynamic type assignment from wrapped function
Browse files Browse the repository at this point in the history
  • Loading branch information
aliev committed Feb 9, 2025
1 parent c6e772f commit 815975f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions aioauth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Set,
Tuple,
Type,
TypeVar,
Union,
)
from urllib.parse import quote, urlencode, urlparse, urlunsplit
Expand Down Expand Up @@ -279,15 +278,9 @@ def build_error_response(
)


T = TypeVar("T")


def catch_errors_and_unavailability(
skip_redirect_on_exc: Tuple[Type[OAuth2Error], ...] = (OAuth2Error,)
) -> Callable[
[Callable[..., Coroutine[Any, Any, T]]],
Callable[..., Coroutine[Any, Any, Union[T, Response]]],
]:
) -> Callable[..., Callable[..., Coroutine[Any, Any, Response]]]:
"""
Decorator that adds error catching to the function passed.
Expand All @@ -298,14 +291,12 @@ def catch_errors_and_unavailability(
"""

def decorator(
f: Callable[..., Coroutine[Any, Any, T]]
) -> Callable[..., Coroutine[Any, Any, Union[T, Response]]]:
f: Callable[..., Coroutine[Any, Any, Response]]
) -> Callable[..., Coroutine[Any, Any, Response]]:
@functools.wraps(f)
async def wrapper(
self, request: Request, *args, **kwargs
) -> Union[T, Response]:
async def wrapper(self, request: Request, *args, **kwargs) -> Response:
try:
response: Union[T, Response] = await f(self, request, *args, **kwargs)
response = await f(self, request, *args, **kwargs)
except Exception as exc:
response = build_error_response(
exc=exc, request=request, skip_redirect_on_exc=skip_redirect_on_exc
Expand Down

0 comments on commit 815975f

Please sign in to comment.