Skip to content

Commit 4020739

Browse files
committed
Minor suggested refactor of if clause (review comment)
1 parent 840ce4f commit 4020739

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/_pytest/python_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -976,11 +976,11 @@ def validate_exc(exc: type[E]) -> type[E]:
976976
origin_exc: type[E] | None = get_origin(exc)
977977
if origin_exc and issubclass(origin_exc, BaseExceptionGroup):
978978
exc_type = get_args(exc)[0]
979-
if issubclass(origin_exc, ExceptionGroup) and exc_type in (Exception, Any):
980-
return cast(type[E], origin_exc)
981-
elif issubclass(origin_exc, BaseExceptionGroup) and exc_type in (
982-
BaseException,
983-
Any,
979+
if (
980+
issubclass(origin_exc, ExceptionGroup) and exc_type in (Exception, Any)
981+
) or (
982+
issubclass(origin_exc, BaseExceptionGroup)
983+
and exc_type in (BaseException, Any)
984984
):
985985
return cast(type[E], origin_exc)
986986
else:

0 commit comments

Comments
 (0)