← eval_submission_nothink

rich_3676

failed WRONG_FIX wrong_fix · 15 tool calls · 80 s · Textualize/rich

Task input

Notes

Add support for Exception.__notes__

Tool calls (16)

#ToolArgumentsResult
1run_command
{
 "command": "grep -rn \"traceback\" rich | grep \"Exception\" | head -20"
}
{"status": "ok", "stdout": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "exit_code": 0}
2run_command
{
 "command": "find rich -name \"*traceback*\""
}
{"status": "ok", "stdout": "rich/traceback.py\n", "exit_code": 0}
full
{"status": "ok", "stdout": "rich/traceback.py\n", "exit_code": 0}
3read_file
{
 "filepath": "rich/traceback.py"
}
{"status": "ok", "filepath": "rich/traceback.py", "content": "import inspect\nimport linecache\nimport os\nimport sys\nfrom dataclasses import dataclass, field\
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "import inspect\nimport linecache\nimport os\nimport sys\nfrom dataclasses import dataclass, field\nfrom itertools import islice\nfrom traceback import walk_tb\nfrom types import ModuleType, TracebackType\nfrom typing import (\n    Any,\n    Callable,\n    Dict,\n    Iterable,\n    List,\n    Optional,\n    Sequence,\n    Tuple,\n    Type,\n    Union,\n)\n\nfrom pygments.lexers import guess_lexer_for_filename\nfrom pygments.token import Comment, Keyword, Name, Number, Operator, String\nfrom pygments.token import Text as TextToken\nfrom pygments.token import Token\nfrom pygments.util import ClassNotFound\n\nfrom . import pretty\nfrom ._loop import loop_last\nfrom .columns import Columns\nfrom .console import Console, ConsoleOptions, ConsoleRenderable, RenderResult, group\nfrom .constrain import Constrain\nfrom .highlighter import RegexHighlighter, ReprHighlighter\nfrom .panel import Panel\nfrom .scope import render_scope\nfrom .style import Style\nfrom .syntax import Syntax\nfrom .text import Text\nfrom .theme import Theme\n\nWINDOWS = sys.platform == \"win32\"\n\nLOCALS_MAX_LENGTH = 10\nLOCALS_MAX_STRING = 80\n\n\ndef install(\n    *,\n    console: Optional[Console] = None,\n    width: Optional[int] = 100,\n    code_width: Optional[int] = 88,\n    extra_lines: int = 3,\n    theme: Optional[str] = None,\n    word_wrap: bool = False,\n    show_locals: bool = False,\n    locals_max_length: int = LOCALS_MAX_LENGTH,\n    locals_max_string: int = LOCALS_MAX_STRING,\n    locals_hide_dunder: bool = True,\n    locals_hide_sunder: Optional[bool] = None,\n    indent_guides: bool = True,\n    suppress: Iterable[Union[str, ModuleType]] = (),\n    max_frames: int = 100,\n) -> Callable[[Type[BaseException], BaseException, Optional[TracebackType]], Any]:\n    \"\"\"Install a rich traceback handler.\n\n    Once installed, any tracebacks will be printed with syntax highlighting and rich formatting.\n\n\n    Args:\n        c
4read_file
{
 "filepath": "rich/traceback.py",
 "start_line": 151,
 "end_line": 797
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " tb = tb.tb_next\n\n excepthook(exc_tuple[0], exc_tuple[1], tb)\n tb_data = {} # clear data upon u
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "                tb = tb.tb_next\n\n            excepthook(exc_tuple[0], exc_tuple[1], tb)\n            tb_data = {}  # clear data upon usage\n\n        # replace _showtraceback instead of showtraceback to allow ipython features such as debugging to work\n        # this is also what the ipython docs recommends to modify when subclassing InteractiveShell\n        ip._showtraceback = ipy_display_traceback\n        # add wrapper to capture tb_data\n        ip.showtraceback = ipy_show_traceback\n        ip.showsyntaxerror = lambda *args, **kwargs: ipy_display_traceback(\n            *args, is_syntax=True, **kwargs\n        )\n\n    try:  # pragma: no cover\n        # if within ipython, use customized traceback\n        ip = get_ipython()  # type: ignore[name-defined]\n        ipy_excepthook_closure(ip)\n        return sys.excepthook\n    except Exception:\n        # otherwise use default system hook\n        old_excepthook = sys.excepthook\n        sys.excepthook = excepthook\n        return old_excepthook\n\n\n@dataclass\nclass Frame:\n    filename: str\n    lineno: int\n    name: str\n    line: str = \"\"\n    locals: Optional[Dict[str, pretty.Node]] = None\n    last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]] = None\n\n\n@dataclass\nclass _SyntaxError:\n    offset: int\n    filename: str\n    line: str\n    lineno: int\n    msg: str\n\n\n@dataclass\nclass Stack:\n    exc_type: str\n    exc_value: str\n    syntax_error: Optional[_SyntaxError] = None\n    is_cause: bool = False\n    frames: List[Frame] = field(default_factory=list)\n\n\n@dataclass\nclass Trace:\n    stacks: List[Stack]\n\n\nclass PathHighlighter(RegexHighlighter):\n    highlights = [r\"(?P<dim>.*/)(?P<bold>.+)\"]\n\n\nclass Traceback:\n    \"\"\"A Console renderable that renders a traceback.\n\n    Args:\n        trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses\n            the
5read_file
{
 "end_line": 400,
 "filepath": "rich/traceback.py",
 "start_line": 301
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " exc_type: Type[Any],\n exc_value: BaseException,\n traceback: Optional[TracebackType],\n *,\n wid
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "        exc_type: Type[Any],\n        exc_value: BaseException,\n        traceback: Optional[TracebackType],\n        *,\n        width: Optional[int] = 100,\n        code_width: Optional[int] = 88,\n        extra_lines: int = 3,\n        theme: Optional[str] = None,\n        word_wrap: bool = False,\n        show_locals: bool = False,\n        locals_max_length: int = LOCALS_MAX_LENGTH,\n        locals_max_string: int = LOCALS_MAX_STRING,\n        locals_hide_dunder: bool = True,\n        locals_hide_sunder: bool = False,\n        indent_guides: bool = True,\n        suppress: Iterable[Union[str, ModuleType]] = (),\n        max_frames: int = 100,\n    ) -> \"Traceback\":\n        \"\"\"Create a traceback from exception info\n\n        Args:\n            exc_type (Type[BaseException]): Exception type.\n            exc_value (BaseException): Exception value.\n            traceback (TracebackType): Python Traceback object.\n            width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.\n            code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.\n            extra_lines (int, optional): Additional lines of code to render. Defaults to 3.\n            theme (str, optional): Override pygments theme used in traceback.\n            word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.\n            show_locals (bool, optional): Enable display of local variables. Defaults to False.\n            indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.\n            locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.\n                Defaults to 10.\n            locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.\n            locals_hide_dunder
6read_file
{
 "end_line": 550,
 "filepath": "rich/traceback.py",
 "start_line": 401
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " stacks: List[Stack] = []\n is_cause = False\n\n from rich import _IMPORT_CWD\n\n def safe_str(_ob
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "        stacks: List[Stack] = []\n        is_cause = False\n\n        from rich import _IMPORT_CWD\n\n        def safe_str(_object: Any) -> str:\n            \"\"\"Don't allow exceptions from __str__ to propagate.\"\"\"\n            try:\n                return str(_object)\n            except Exception:\n                return \"<exception str() failed>\"\n\n        while True:\n            stack = Stack(\n                exc_type=safe_str(exc_type.__name__),\n                exc_value=safe_str(exc_value),\n                is_cause=is_cause,\n            )\n\n            if isinstance(exc_value, SyntaxError):\n                stack.syntax_error = _SyntaxError(\n                    offset=exc_value.offset or 0,\n                    filename=exc_value.filename or \"?\",\n                    lineno=exc_value.lineno or 0,\n                    line=exc_value.text or \"\",\n                    msg=exc_value.msg,\n                )\n\n            stacks.append(stack)\n            append = stack.frames.append\n\n            def get_locals(\n                iter_locals: Iterable[Tuple[str, object]]\n            ) -> Iterable[Tuple[str, object]]:\n                \"\"\"Extract locals from an iterator of key pairs.\"\"\"\n                if not (locals_hide_dunder or locals_hide_sunder):\n                    yield from iter_locals\n                    return\n                for key, value in iter_locals:\n                    if locals_hide_dunder and key.startswith(\"__\"):\n                        continue\n                    if locals_hide_sunder and key.startswith(\"_\"):\n                        continue\n                    yield key, value\n\n            for frame_summary, line_no in walk_tb(traceback):\n                filename = frame_summary.f_code.co_filename\n\n                last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]]\n                last_instruction = None\n                i
7read_file
{
 "end_line": 797,
 "filepath": "rich/traceback.py",
 "start_line": 551
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " \"scope.equals\": token_style(Operator),\n \"scope.key\": token_style(Name),\n \"scope.key.specia
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "                \"scope.equals\": token_style(Operator),\n                \"scope.key\": token_style(Name),\n                \"scope.key.special\": token_style(Name.Constant) + Style(dim=True),\n            },\n            inherit=False,\n        )\n\n        highlighter = ReprHighlighter()\n        for last, stack in loop_last(reversed(self.trace.stacks)):\n            if stack.frames:\n                stack_renderable: ConsoleRenderable = Panel(\n                    self._render_stack(stack),\n                    title=\"[traceback.title]Traceback [dim](most recent call last)\",\n                    style=background_style,\n                    border_style=\"traceback.border\",\n                    expand=True,\n                    padding=(0, 1),\n                )\n                stack_renderable = Constrain(stack_renderable, self.width)\n                with console.use_theme(traceback_theme):\n                    yield stack_renderable\n            if stack.syntax_error is not None:\n                with console.use_theme(traceback_theme):\n                    yield Constrain(\n                        Panel(\n                            self._render_syntax_error(stack.syntax_error),\n                            style=background_style,\n                            border_style=\"traceback.border.syntax_error\",\n                            expand=True,\n                            padding=(0, 1),\n                            width=self.width,\n                        ),\n                        self.width,\n                    )\n                yield Text.assemble(\n                    (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                    highlighter(stack.syntax_error.msg),\n                )\n            elif stack.exc_value:\n                yield Text.assemble(\n                    (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                    highlighter(stack.exc_va
8run_command
{
 "command": "python3 -c \"\ntry:\n    raise ValueError('test error')\nexcept ValueError as e:\n    e.__notes__ = 'test note'\n    print(f'Notes: {e.__notes__}')\n\""
}
{"status": "ok", "stdout": "Notes: test note\n", "exit_code": 0}
full
{"status": "ok", "stdout": "Notes: test note\n", "exit_code": 0}
9read_file
{
 "end_line": 650,
 "filepath": "rich/traceback.py",
 "start_line": 401
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " stacks: List[Stack] = []\n is_cause = False\n\n from rich import _IMPORT_CWD\n\n def safe_str(_ob
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "        stacks: List[Stack] = []\n        is_cause = False\n\n        from rich import _IMPORT_CWD\n\n        def safe_str(_object: Any) -> str:\n            \"\"\"Don't allow exceptions from __str__ to propagate.\"\"\"\n            try:\n                return str(_object)\n            except Exception:\n                return \"<exception str() failed>\"\n\n        while True:\n            stack = Stack(\n                exc_type=safe_str(exc_type.__name__),\n                exc_value=safe_str(exc_value),\n                is_cause=is_cause,\n            )\n\n            if isinstance(exc_value, SyntaxError):\n                stack.syntax_error = _SyntaxError(\n                    offset=exc_value.offset or 0,\n                    filename=exc_value.filename or \"?\",\n                    lineno=exc_value.lineno or 0,\n                    line=exc_value.text or \"\",\n                    msg=exc_value.msg,\n                )\n\n            stacks.append(stack)\n            append = stack.frames.append\n\n            def get_locals(\n                iter_locals: Iterable[Tuple[str, object]]\n            ) -> Iterable[Tuple[str, object]]:\n                \"\"\"Extract locals from an iterator of key pairs.\"\"\"\n                if not (locals_hide_dunder or locals_hide_sunder):\n                    yield from iter_locals\n                    return\n                for key, value in iter_locals:\n                    if locals_hide_dunder and key.startswith(\"__\"):\n                        continue\n                    if locals_hide_sunder and key.startswith(\"_\"):\n                        continue\n                    yield key, value\n\n            for frame_summary, line_no in walk_tb(traceback):\n                filename = frame_summary.f_code.co_filename\n\n                last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]]\n                last_instruction = None\n                i
10read_file
{
 "end_line": 250,
 "filepath": "rich/traceback.py",
 "start_line": 180
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " lineno: int\n name: str\n line: str = \"\"\n locals: Optional[Dict[str, pretty.Node]] = None\n la
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "    lineno: int\n    name: str\n    line: str = \"\"\n    locals: Optional[Dict[str, pretty.Node]] = None\n    last_instruction: Optional[Tuple[Tuple[int, int], Tuple[int, int]]] = None\n\n\n@dataclass\nclass _SyntaxError:\n    offset: int\n    filename: str\n    line: str\n    lineno: int\n    msg: str\n\n\n@dataclass\nclass Stack:\n    exc_type: str\n    exc_value: str\n    syntax_error: Optional[_SyntaxError] = None\n    is_cause: bool = False\n    frames: List[Frame] = field(default_factory=list)\n\n\n@dataclass\nclass Trace:\n    stacks: List[Stack]\n\n\nclass PathHighlighter(RegexHighlighter):\n    highlights = [r\"(?P<dim>.*/)(?P<bold>.+)\"]\n\n\nclass Traceback:\n    \"\"\"A Console renderable that renders a traceback.\n\n    Args:\n        trace (Trace, optional): A `Trace` object produced from `extract`. Defaults to None, which uses\n            the last exception.\n        width (Optional[int], optional): Number of characters used to traceback. Defaults to 100.\n        code_width (Optional[int], optional): Number of code characters used to traceback. Defaults to 88.\n        extra_lines (int, optional): Additional lines of code to render. Defaults to 3.\n        theme (str, optional): Override pygments theme used in traceback.\n        word_wrap (bool, optional): Enable word wrapping of long lines. Defaults to False.\n        show_locals (bool, optional): Enable display of local variables. Defaults to False.\n        indent_guides (bool, optional): Enable indent guides in code and locals. Defaults to True.\n        locals_max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.\n            Defaults to 10.\n        locals_max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to 80.\n        locals_hide_dunder (bool, optional): Hide locals prefixed with double underscore. Defaults to True.\n        
11edit_file
{
 "filepath": "rich/traceback.py",
 "new_string": "@dataclass\nclass Stack:\n    exc_type: str\n    exc_value: str\n    notes: Optional[str] = None\n    syntax_error: Optional[_SyntaxError] = None\n    is_cause: bool = False\n    frames: List[Frame] = field(default_factory=list)",
 "old_string": "@dataclass\nclass Stack:\n    exc_type: str\n    exc_value: str\n    syntax_error: Optional[_SyntaxError] = None\n    is_cause: bool = False\n    frames: List[Frame] = field(default_factory=list)"
}
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -197,6 +1
full
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -197,6 +197,7 @@\n class Stack:\n     exc_type: str\n     exc_value: str\n+    notes: Optional[str] = None\n     syntax_error: Optional[_SyntaxError] = None\n     is_cause: bool = False\n     frames: List[Frame] = field(default_factory=list)\n", "is_truncated": false}
12edit_file
{
 "filepath": "rich/traceback.py",
 "new_string": "        while True:\n            stack = Stack(\n                exc_type=safe_str(exc_type.__name__),\n                exc_value=safe_str(exc_value),\n                notes=safe_str(getattr(exc_value, \"__notes__\", None)) if getattr(exc_value, \"__notes__\", None) else None,\n                is_cause=is_cause,\n            )",
 "old_string": "        while True:\n            stack = Stack(\n                exc_type=safe_str(exc_type.__name__),\n                exc_value=safe_str(exc_value),\n                is_cause=is_cause,\n            )"
}
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -415,6 +4
full
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -415,6 +415,7 @@\n             stack = Stack(\n                 exc_type=safe_str(exc_type.__name__),\n                 exc_value=safe_str(exc_value),\n+                notes=safe_str(getattr(exc_value, \"__notes__\", None)) if getattr(exc_value, \"__notes__\", None) else None,\n                 is_cause=is_cause,\n             )\n \n", "is_truncated": false}
13read_file
{
 "end_line": 650,
 "filepath": "rich/traceback.py",
 "start_line": 551
}
{"status": "ok", "filepath": "rich/traceback.py", "content": " \"repr.none\": token_style(Keyword.Constant),\n \"scope.border\": token_style(String.Delimiter),\
full
{"status": "ok", "filepath": "rich/traceback.py", "content": "                \"repr.none\": token_style(Keyword.Constant),\n                \"scope.border\": token_style(String.Delimiter),\n                \"scope.equals\": token_style(Operator),\n                \"scope.key\": token_style(Name),\n                \"scope.key.special\": token_style(Name.Constant) + Style(dim=True),\n            },\n            inherit=False,\n        )\n\n        highlighter = ReprHighlighter()\n        for last, stack in loop_last(reversed(self.trace.stacks)):\n            if stack.frames:\n                stack_renderable: ConsoleRenderable = Panel(\n                    self._render_stack(stack),\n                    title=\"[traceback.title]Traceback [dim](most recent call last)\",\n                    style=background_style,\n                    border_style=\"traceback.border\",\n                    expand=True,\n                    padding=(0, 1),\n                )\n                stack_renderable = Constrain(stack_renderable, self.width)\n                with console.use_theme(traceback_theme):\n                    yield stack_renderable\n            if stack.syntax_error is not None:\n                with console.use_theme(traceback_theme):\n                    yield Constrain(\n                        Panel(\n                            self._render_syntax_error(stack.syntax_error),\n                            style=background_style,\n                            border_style=\"traceback.border.syntax_error\",\n                            expand=True,\n                            padding=(0, 1),\n                            width=self.width,\n                        ),\n                        self.width,\n                    )\n                yield Text.assemble(\n                    (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                    highlighter(stack.syntax_error.msg),\n                )\n            elif stack.exc_value:\n                yield Tex
14edit_file
{
 "filepath": "rich/traceback.py",
 "new_string": "            elif stack.exc_value:\n                yield Text.assemble(\n                    (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                    highlighter(stack.exc_value),\n                )\n                if stack.notes:\n                    yield Text.assemble(\n                        (\"\\n\", \"pygments.text\"),\n                        (\"Notes: \", \"traceback.exc_type\"),\n                        highlighter(stack.notes),\n                    )\n            else:\n                yield Text.assemble((f\"{stack.exc_type}\", \"traceback.exc_type\"))",
 "old_string": "            elif stack.exc_value:\n                yield Text.assemble(\n                    (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                    highlighter(stack.exc_value),\n                )\n            else:\n                yield Text.assemble((f\"{stack.exc_type}\", \"traceback.exc_type\"))"
}
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -593,6 +5
full
{"status": "ok", "filepath": "rich/traceback.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/traceback.py\n+++ b/rich/traceback.py\n@@ -593,6 +593,12 @@\n                     (f\"{stack.exc_type}: \", \"traceback.exc_type\"),\n                     highlighter(stack.exc_value),\n                 )\n+                if stack.notes:\n+                    yield Text.assemble(\n+                        (\"\\n\", \"pygments.text\"),\n+                        (\"Notes: \", \"traceback.exc_type\"),\n+                        highlighter(stack.notes),\n+                    )\n             else:\n                 yield Text.assemble((f\"{stack.exc_type}\", \"traceback.exc_type\"))\n \n", "is_truncated": false}
15run_command
{
 "command": "python3 -c \"\nfrom rich.console import Console\nfrom rich.traceback import Traceback\nimport sys\n\nconsole = Console(force_terminal=True)\ntry:\n    raise ValueError('test error')\nexcept ValueError as e:\n    e.__notes__ = 'test note'\n    tb = Traceback.from_exception(type(e), e, e.__traceback__)\n    console.print(tb)\n\""
}
{"status": "ok", "stdout": "\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
full
{"status": "ok", "stdout": "\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Traceback (most recent call last) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256e\n\u2502 in <module>:8                                                                \u2502\n\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256f\nValueError: test error\n\nNotes: test note\n", "exit_code": 0}
16submit_patch
[]
{"status": "ok", "patch_size": 1271, "files_changed": 1}
full
{"status": "ok", "patch_size": 1271, "files_changed": 1}

Patch

diff --git a/rich/traceback.py b/rich/traceback.py
index 3bf5baa7..4b598caf 100644
--- a/rich/traceback.py
+++ b/rich/traceback.py
@@ -197,6 +197,7 @@ class _SyntaxError:
 class Stack:
     exc_type: str
     exc_value: str
+    notes: Optional[str] = None
     syntax_error: Optional[_SyntaxError] = None
     is_cause: bool = False
     frames: List[Frame] = field(default_factory=list)
@@ -414,6 +415,7 @@ class Traceback:
             stack = Stack(
                 exc_type=safe_str(exc_type.__name__),
                 exc_value=safe_str(exc_value),
+                notes=safe_str(getattr(exc_value, "__notes__", None)) if getattr(exc_value, "__notes__", None) else None,
                 is_cause=is_cause,
             )
 
@@ -591,6 +593,12 @@ class Traceback:
                     (f"{stack.exc_type}: ", "traceback.exc_type"),
                     highlighter(stack.exc_value),
                 )
+                if stack.notes:
+                    yield Text.assemble(
+                        ("\n", "pygments.text"),
+                        ("Notes: ", "traceback.exc_type"),
+                        highlighter(stack.notes),
+                    )
             else:
                 yield Text.assemble((f"{stack.exc_type}", "traceback.exc_type"))
 

Test output

show
...................s.F
=================================== FAILURES ===================================
__________________________________ test_notes __________________________________

    @pytest.mark.skipif(
        sys.version_info.minor < 11, reason="Not supported before Python 3.11"
    )
    def test_notes() -> None:
        """Check traceback captures __note__."""
        try:
>           1 / 0
E           ZeroDivisionError: division by zero
E           Hello
E           World

tests/test_traceback.py:369: ZeroDivisionError

During handling of the above exception, another exception occurred:

    @pytest.mark.skipif(
        sys.version_info.minor < 11, reason="Not supported before Python 3.11"
    )
    def test_notes() -> None:
        """Check traceback captures __note__."""
        try:
            1 / 0
        except Exception as error:
            error.add_note("Hello")
            error.add_note("World")
            traceback = Traceback()
    
>           assert traceback.trace.stacks[0].notes == ["Hello", "World"]
E           assert "['Hello', 'World']" == ['Hello', 'World']
E            +  where "['Hello', 'World']" = Stack(exc_type='ZeroDivisionError', exc_value='division by zero', notes="['Hello', 'World']", syntax_error=None, is_ca...sts/test_traceback.py', lineno=369, name='test_notes', line='', locals=None, last_instruction=((373, 20), (373, 31)))]).notes

tests/test_traceback.py:375: AssertionError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 20 passed, 1 skipped in 0.85s