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

Code before:
            outcome: Literal["passed", "failed", "skipped"] = "passed"
            longrepr: (
                None
                | ExceptionInfo[BaseException]
                | tuple[str, int, str]
                | 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):
                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,

Review comment (refactor):
The annotation shouldn't be needed.

More generally I suggest dropping the `value` helper variable, using `excinfo.value` would be more direct.

Code after:
        if not call.excinfo:
            outcome: Literal["passed", "failed", "skipped"] = "passed"
            longrepr: (
                None
                | ExceptionInfo[BaseException]
                | tuple[str, int, str]
                | 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,