Skip to content

Commit 1d2ebb7

Browse files
Split wrapper functions to async and sync (#2473)
* Split wrapper functions to asyncr and sync * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3fd6725 commit 1d2ebb7

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎returns/contrib/pytest/plugin.py‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,19 @@ def _patched_error_handler(
180180
) -> _FunctionType:
181181
if inspect.iscoroutinefunction(original):
182182

183-
async def wrapper(self, *args, **kwargs):
183+
async def async_wrapper(self, *args, **kwargs):
184184
original_result = await original(self, *args, **kwargs)
185185
errs[id(original_result)] = original_result
186186
return original_result
187187

188-
else:
188+
return wraps(original)(async_wrapper) # type: ignore
189189

190-
def wrapper(self, *args, **kwargs):
191-
original_result = original(self, *args, **kwargs)
192-
errs[id(original_result)] = original_result
193-
return original_result
190+
def sync_wrapper(self, *args, **kwargs):
191+
original_result = original(self, *args, **kwargs)
192+
errs[id(original_result)] = original_result
193+
return original_result
194194

195-
return wraps(original)(wrapper) # type: ignore
195+
return wraps(original)(sync_wrapper) # type: ignore
196196

197197

198198
def _patched_error_copier(
@@ -201,21 +201,21 @@ def _patched_error_copier(
201201
) -> _FunctionType:
202202
if inspect.iscoroutinefunction(original):
203203

204-
async def wrapper(self, *args, **kwargs):
204+
async def async_wrapper(self, *args, **kwargs):
205205
original_result = await original(self, *args, **kwargs)
206206
if id(self) in errs:
207207
errs[id(original_result)] = original_result
208208
return original_result
209209

210-
else:
210+
return wraps(original)(async_wrapper) # type: ignore
211211

212-
def wrapper(self, *args, **kwargs):
213-
original_result = original(self, *args, **kwargs)
214-
if id(self) in errs:
215-
errs[id(original_result)] = original_result
216-
return original_result
212+
def sync_wrapper(self, *args, **kwargs):
213+
original_result = original(self, *args, **kwargs)
214+
if id(self) in errs:
215+
errs[id(original_result)] = original_result
216+
return original_result
217217

218-
return wraps(original)(wrapper) # type: ignore
218+
return wraps(original)(sync_wrapper) # type: ignore
219219

220220

221221
_ERROR_HANDLING_PATCHERS: Final = MappingProxyType({

0 commit comments

Comments
 (0)