From cac19a7b4df9fdba04a6856c47595c92ba799e11 Mon Sep 17 00:00:00 2001 From: kodsurfer <86408225+kodsurfer@users.noreply.github.com> Date: Thu, 30 Jul 2026 12:41:05 +0300 Subject: [PATCH 1/2] Split wrapper functions to asyncr and sync --- returns/contrib/pytest/plugin.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/returns/contrib/pytest/plugin.py b/returns/contrib/pytest/plugin.py index 046c96aa5..901b8de12 100644 --- a/returns/contrib/pytest/plugin.py +++ b/returns/contrib/pytest/plugin.py @@ -180,20 +180,19 @@ def _patched_error_handler( ) -> _FunctionType: if inspect.iscoroutinefunction(original): - async def wrapper(self, *args, **kwargs): + async def async_wrapper(self, *args, **kwargs): original_result = await original(self, *args, **kwargs) errs[id(original_result)] = original_result return original_result - else: + return wraps(original)(async_wrapper) # type: ignore - def wrapper(self, *args, **kwargs): - original_result = original(self, *args, **kwargs) - errs[id(original_result)] = original_result - return original_result - - return wraps(original)(wrapper) # type: ignore + def sync_wrapper(self, *args, **kwargs): + original_result = original(self, *args, **kwargs) + errs[id(original_result)] = original_result + return original_result + return wraps(original)(sync_wrapper) # type: ignore def _patched_error_copier( original: _FunctionType, @@ -201,22 +200,21 @@ def _patched_error_copier( ) -> _FunctionType: if inspect.iscoroutinefunction(original): - async def wrapper(self, *args, **kwargs): + async def async_wrapper(self, *args, **kwargs): original_result = await original(self, *args, **kwargs) if id(self) in errs: errs[id(original_result)] = original_result return original_result - else: - - def wrapper(self, *args, **kwargs): - original_result = original(self, *args, **kwargs) - if id(self) in errs: - errs[id(original_result)] = original_result - return original_result + return wraps(original)(async_wrapper) # type: ignore - return wraps(original)(wrapper) # type: ignore + def sync_wrapper(self, *args, **kwargs): + original_result = original(self, *args, **kwargs) + if id(self) in errs: + errs[id(original_result)] = original_result + return original_result + return wraps(original)(sync_wrapper) # type: ignore _ERROR_HANDLING_PATCHERS: Final = MappingProxyType({ 'lash': _patched_error_handler, From 29e1284aaaf3e9764de0fea6c4aa229766646152 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 09:43:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- returns/contrib/pytest/plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/returns/contrib/pytest/plugin.py b/returns/contrib/pytest/plugin.py index 901b8de12..b08a16aea 100644 --- a/returns/contrib/pytest/plugin.py +++ b/returns/contrib/pytest/plugin.py @@ -194,6 +194,7 @@ def sync_wrapper(self, *args, **kwargs): return wraps(original)(sync_wrapper) # type: ignore + def _patched_error_copier( original: _FunctionType, errs: _ErrorsHandled, @@ -216,6 +217,7 @@ def sync_wrapper(self, *args, **kwargs): return wraps(original)(sync_wrapper) # type: ignore + _ERROR_HANDLING_PATCHERS: Final = MappingProxyType({ 'lash': _patched_error_handler, 'map': _patched_error_copier,