def get_source(
        self,
        source: Source | None,
        line_index: int = -1,
        excinfo: ExceptionInfo[BaseException] | None = None,
        short: bool = False,
        end_line_index: int | None = None,
        colno: int | None = None,
        end_colno: int | None = None,
    ) -> list[str]:
        """Return formatted and marked up source lines."""
        lines = []
        if source is not None and line_index < 0:
            line_index += len(source)
        if source is None or line_index >= len(source.lines) or line_index < 0:
            # `line_index` could still be outside `range(len(source.lines))` if
            # we're processing AST with pathological position attributes.
            source = Source("???")
            line_index = 0
        space_prefix = "    "
        if short:
            lines.append(space_prefix + source.lines[line_index].strip())
            lines.extend(
                self.get_highlight_arrows_for_line(
                    raw_line=source.raw_lines[line_index],
                    line=source.lines[line_index].strip(),
                    lineno=line_index,
                    end_lineno=end_line_index,
                    colno=colno,
                    end_colno=end_colno,
                )
            )
        else:
            for line in source.lines[:line_index]:
                lines.append(space_prefix + line)
            lines.append(self.flow_marker + "   " + source.lines[line_index])
            lines.extend(
                self.get_highlight_arrows_for_line(
                    raw_line=source.raw_lines[line_index],
                    line=source.lines[line_index],
                    lineno=line_index,
                    end_lineno=end_line_index,
                    colno=colno,
                    end_colno=end_colno,
                )
            )
            for line in source.lines[line_index + 1 :]:
                lines.append(space_prefix + line)
        if excinfo is not None:
            indent = 4 if short else self._getindent(source)
            lines.extend(self.get_exconly(excinfo, indent=indent, markall=True))
        return lines
Return formatted and marked up source lines.
src/_pytest/_code/code.py