Repository: pytest-dev/pytest
File: src/_pytest/reports.py (Python)

Code before:
                | TerminalRepr
            ) = None
        else:
            if not isinstance(excinfo, ExceptionInfo):
                outcome = "failed"
                longrepr = excinfo
            elif isinstance(excinfo.value, skip.Exception):
                outcome = "skipped"
                r = excinfo._getreprcrash()
                assert r is not None, (
                    "There should always be a traceback entry for skipping a test."
                )
                if excinfo.value._use_item_location:
                    path, line = item.reportinfo()[:2]
                    assert line is not None
                    longrepr = (os.fspath(path), line + 1, r.message)
                else:
                    longrepr = (str(r.path), r.lineno, r.message)
            elif isinstance(excinfo.value, BaseExceptionGroup):
                value: BaseExceptionGroup = excinfo.value
                if value.exceptions and any(
                    isinstance(exception, skip.Exception)
                    for exception in value.exceptions
                ):
                    outcome = "skipped"
                    skipped_exceptions = cast(list[Skipped], value.exceptions)
                    longrepr = _format_exception_group_all_skipped_longrepr(
                        item, excinfo, skipped_exceptions
                    )
                else:
                    # fall through to your existing failure path
                    outcome = "failed"
                    longrepr = _format_failed_longrepr(item, call, excinfo)
            else:
                outcome = "failed"
                longrepr = _format_failed_longrepr(item, call, excinfo)
        for rwhen, key, content in item._report_sections:
            sections.append((f"Captured {key} {rwhen}", content))
        return cls(
            item.nodeid,
            item.location,
            keywords,
            outcome,
            longrepr,
            when,
            sections,
            duration,
            start,
            stop,
            user_properties=item.user_properties,
        )

Review comment (suggestion):
This cast is not correct, since you're using `any` there may be other types of exceptions.

Code after:
                | str
                | TerminalRepr
            ) = None
        else:
            if not isinstance(excinfo, ExceptionInfo):
                outcome = "failed"
                longrepr = excinfo
            elif isinstance(excinfo.value, skip.Exception):
                outcome = "skipped"
                r = excinfo._getreprcrash()
                assert r is not None, (
                    "There should always be a traceback entry for skipping a test."
                )
                if excinfo.value._use_item_location:
                    path, line = item.reportinfo()[:2]
                    assert line is not None
                    longrepr = (os.fspath(path), line + 1, r.message)
                else:
                    longrepr = (str(r.path), r.lineno, r.message)
            elif isinstance(excinfo.value, BaseExceptionGroup) and (
                excinfo.value.split(skip.Exception)[1] is None
            ):
                # All exceptions in the group are skip exceptions.
                outcome = "skipped"
                excinfo = cast(
                    ExceptionInfo[
                        BaseExceptionGroup[BaseException | BaseExceptionGroup]
                    ],
                    excinfo,
                )
                longrepr = _format_exception_group_all_skipped_longrepr(item, excinfo)
            else:
                outcome = "failed"
                longrepr = _format_failed_longrepr(item, call, excinfo)
        for rwhen, key, content in item._report_sections:
            sections.append((f"Captured {key} {rwhen}", content))
        return cls(
            item.nodeid,
            item.location,
            keywords,
            outcome,
            longrepr,
            when,
            sections,
            duration,
            start,
            stop,
            user_properties=item.user_properties,
        )