failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(budget) · 6 tool calls · 305 s · Textualize/rich
fix(panel): fix title missing panel background
Fix `Panel` title missing the panel background style.
This really just reverts the change in 7a38204. There's a history of issues related to the panel title styles, so I was careful to run all the examples in those issues to ensure there wasn't any regression.
Fixes #3569
## Type of changes
- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other
## Checklist
- [x] I've run the latest [black](https://github.com/psf/black) with default args on new code.
- [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.
| # | Tool | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"Panel\" rich | grep \"title\" | head -20"
} | {"status": "ok", "stdout": "rich/diagnose.py:33: console.print(Panel.fit((Pretty(env)), title=\"[b]Environment Variables\"))\nrich/panel.py:311: title=\"rich.Pafull{"status": "ok", "stdout": "rich/diagnose.py:33: console.print(Panel.fit((Pretty(env)), title=\"[b]Environment Variables\"))\nrich/panel.py:311: title=\"rich.Panel\",\n", "exit_code": 0} |
| 2 | read_file | {
"filepath": "rich/panel.py"
} | {"status": "ok", "filepath": "rich/panel.py", "content": "from typing import TYPE_CHECKING, Optional\n\nfrom .align import AlignMethod\nfrom .box import ROUNDEDfull{"status": "ok", "filepath": "rich/panel.py", "content": "from typing import TYPE_CHECKING, Optional\n\nfrom .align import AlignMethod\nfrom .box import ROUNDED, Box\nfrom .cells import cell_len\nfrom .jupyter import JupyterMixin\nfrom .measure import Measurement, measure_renderables\nfrom .padding import Padding, PaddingDimensions\nfrom .segment import Segment\nfrom .style import Style, StyleType\nfrom .text import Text, TextType\n\nif TYPE_CHECKING:\n from .console import Console, ConsoleOptions, RenderableType, RenderResult\n\n\nclass Panel(JupyterMixin):\n \"\"\"A console renderable that draws a border around its contents.\n\n Example:\n >>> console.print(Panel(\"Hello, World!\"))\n\n Args:\n renderable (RenderableType): A console renderable object.\n box (Box): A Box instance that defines the look of the border (see :ref:`appendix_box`. Defaults to box.ROUNDED.\n title (Optional[TextType], optional): Optional title displayed in panel header. Defaults to None.\n title_align (AlignMethod, optional): Alignment of title. Defaults to \"center\".\n subtitle (Optional[TextType], optional): Optional subtitle displayed in panel footer. Defaults to None.\n subtitle_align (AlignMethod, optional): Alignment of subtitle. Defaults to \"center\".\n safe_box (bool, optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.\n expand (bool, optional): If True the panel will stretch to fill the console width, otherwise it will be sized to fit the contents. Defaults to True.\n style (str, optional): The style of the panel (border and contents). Defaults to \"none\".\n border_style (str, optional): The style of the border. Defaults to \"none\".\n width (Optional[int], optional): Optional width of panel. Defaults to None to auto-detect.\n height (Optional[int], optional): Optional height of panel. Defaults to None to auto- |
| 3 | read_file | {
"filepath": "rich/panel.py",
"start_line": 151,
"end_line": 318
} | {"status": "ok", "filepath": "rich/panel.py", "content": " width = (\n options.max_width\n if self.width is None\n else min(options.max_width, self.width)\n )\nfull{"status": "ok", "filepath": "rich/panel.py", "content": " width = (\n options.max_width\n if self.width is None\n else min(options.max_width, self.width)\n )\n\n safe_box: bool = console.safe_box if self.safe_box is None else self.safe_box\n box = self.box.substitute(options, safe=safe_box)\n\n def align_text(\n text: Text, width: int, align: str, character: str, style: Style\n ) -> Text:\n \"\"\"Gets new aligned text.\n\n Args:\n text (Text): Title or subtitle text.\n width (int): Desired width.\n align (str): Alignment.\n character (str): Character for alignment.\n style (Style): Border style\n\n Returns:\n Text: New text instance\n \"\"\"\n text = text.copy()\n text.truncate(width)\n excess_space = width - cell_len(text.plain)\n if text.style:\n text.stylize(console.get_style(text.style))\n\n if excess_space:\n if align == \"left\":\n return Text.assemble(\n text,\n (character * excess_space, style),\n no_wrap=True,\n end=\"\",\n )\n elif align == \"center\":\n left = excess_space // 2\n return Text.assemble(\n (character * left, style),\n text,\n (character * (excess_space - left), style),\n no_wrap=True,\n end=\"\",\n )\n else:\n return Text.assemble(\n (character * excess_space, style),\n text,\n no_wrap=True,\n end=\"\",\n |
| 4 | run_command | {
"command": "python3 -c \"from rich.console import Console; from rich.panel import Panel; console = Console(force_terminal=True, width=40); panel = Panel('Content', title='Title', style='on blue', border_style='white'); console.print(panel)\""
} | {"status": "ok", "stdout": "\u256d\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500full{"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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Title \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\u256e\n\u2502 Content \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\n", "exit_code": 0} |
| 5 | read_file | {
"filepath": "rich/panel.py",
"start_line": 140,
"end_line": 160
} | {"status": "ok", "filepath": "rich/panel.py", "content": "\n def __rich_console__(\n self, console: \"Console\", options: \"ConsoleOptions\"\n ) -> \"RenderResufull{"status": "ok", "filepath": "rich/panel.py", "content": "\n def __rich_console__(\n self, console: \"Console\", options: \"ConsoleOptions\"\n ) -> \"RenderResult\":\n _padding = Padding.unpack(self.padding)\n renderable = (\n Padding(self.renderable, _padding) if any(_padding) else self.renderable\n )\n style = console.get_style(self.style)\n partial_border_style = console.get_style(self.border_style)\n border_style = style + partial_border_style\n width = (\n options.max_width\n if self.width is None\n else min(options.max_width, self.width)\n )\n\n safe_box: bool = console.safe_box if self.safe_box is None else self.safe_box\n box = self.box.substitute(options, safe=safe_box)\n\n def align_text(\n", "start_line": 140, "end_line": 160, "total_lines": 318, "is_truncated": false} |
| 6 | read_file | {
"end_line": 220,
"filepath": "rich/panel.py",
"start_line": 161
} | {"status": "ok", "filepath": "rich/panel.py", "content": " text: Text, width: int, align: str, character: str, style: Style\n ) -> Text:\n \"\"\"Gets new alignefull{"status": "ok", "filepath": "rich/panel.py", "content": " text: Text, width: int, align: str, character: str, style: Style\n ) -> Text:\n \"\"\"Gets new aligned text.\n\n Args:\n text (Text): Title or subtitle text.\n width (int): Desired width.\n align (str): Alignment.\n character (str): Character for alignment.\n style (Style): Border style\n\n Returns:\n Text: New text instance\n \"\"\"\n text = text.copy()\n text.truncate(width)\n excess_space = width - cell_len(text.plain)\n if text.style:\n text.stylize(console.get_style(text.style))\n\n if excess_space:\n if align == \"left\":\n return Text.assemble(\n text,\n (character * excess_space, style),\n no_wrap=True,\n end=\"\",\n )\n elif align == \"center\":\n left = excess_space // 2\n return Text.assemble(\n (character * left, style),\n text,\n (character * (excess_space - left), style),\n no_wrap=True,\n end=\"\",\n )\n else:\n return Text.assemble(\n (character * excess_space, style),\n text,\n no_wrap=True,\n end=\"\",\n )\n return text\n\n title_text = self._title\n if title_text is not None:\n title_text.stylize_before(partial_border_style)\n\n child_width = (\n width - 2\n if self.expand\n else console.measure(\n renderable, opti |