Skip to content

Commit 8ebf3a4

Browse files
committed
flip the conditional to reduce nesting level
1 parent 7692e30 commit 8ebf3a4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/_pytest/recwarn.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ def deprecated_call(
8686
__tracebackhide__ = True
8787
# potential QoL: allow `with deprecated_call:` - i.e. no parens
8888
dep_warnings = (DeprecationWarning, PendingDeprecationWarning, FutureWarning)
89-
if func is not None:
90-
warnings.warn(CALLABLE_DEPRECATED_CALL, stacklevel=2)
91-
with warns(dep_warnings):
92-
return func(*args, **kwargs)
93-
return warns(dep_warnings, *args, **kwargs)
89+
if func is None:
90+
return warns(dep_warnings, *args, **kwargs)
91+
92+
warnings.warn(CALLABLE_DEPRECATED_CALL, stacklevel=2)
93+
with warns(dep_warnings):
94+
return func(*args, **kwargs)
9495

9596

9697
@overload

0 commit comments

Comments
 (0)