← eval8_submission_v1l

rich_3905

resolved RESOLVED PASS · 14 tool calls · 232 s · Textualize/rich

Task input

Update progress.py

Don't output extraneous blank line when progress display is disabled


<!--
Please note that Rich isn't accepting any new features at this point.

If a feature can be implemented without modifying the core library, then
they should be released as a third-party module. I can accept updates to the
core library that make it easier to extend (think hooks).

Bugfixes are always welcome of course.

Sometimes it is not clear what is a feature and what is a bug fix.
If there is any doubt, please open a discussion first.

-->

<!--
*Are you contributing typo fixes?*

If your PR solely consists of typos, at least one must be in the docs to warrant an addition to CONTRIBUTORS.md
-->

## Type of changes

- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [ ] Other

## AI?

- [ ] AI was used to generate this PR

AI generated PRs may be accepted, but only if @willmcgugan has responded on an issue or discussion.

## 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 (see note about typos above).
- [x] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.

## Description

When creating a `Progress` with `disabled=True`, it still outputs a blank line on non interactive consoles. This PR adds an `if not self.disable` to the `stop` function, symmetrically to the `start` function.

**Important:** Link to an issue or discussion regarding these changes. 

https://github.com/Textualize/rich/issues/110

Tool calls (15)

#ToolArgumentsResult
1run_command
{
 "command": "find . -name \"progress.py\""
}
{"status": "ok", "stdout": "./rich/progress.py\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "./rich/progress.py\n", "stderr": "", "exit_code": 0}
2run_command
{
 "command": "grep -n \"def stop\" rich/progress.py"
}
{"status": "ok", "stdout": "1173: def stop(self) -> None:\n1401: def stop_task(self, task_id: TaskID) -> None:\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "1173:    def stop(self) -> None:\n1401:    def stop_task(self, task_id: TaskID) -> None:\n", "stderr": "", "exit_code": 0}
3run_command
{
 "command": "sed -n '1173,1200p' rich/progress.py"
}
{"status": "ok", "stdout": " def stop(self) -> None:\n \"\"\"Stop the progress display.\"\"\"\n self.live.stop()\n if not self.console.is_interactive and not se
full
{"status": "ok", "stdout": "    def stop(self) -> None:\n        \"\"\"Stop the progress display.\"\"\"\n        self.live.stop()\n        if not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()\n\n    def __enter__(self) -> Self:\n        self.start()\n        return self\n\n    def __exit__(\n        self,\n        exc_type: Optional[Type[BaseException]],\n        exc_val: Optional[BaseException],\n        exc_tb: Optional[TracebackType],\n    ) -> None:\n        self.stop()\n\n    def track(\n        self,\n        sequence: Iterable[ProgressType],\n        total: Optional[float] = None,\n        completed: int = 0,\n        task_id: Optional[TaskID] = None,\n        description: str = \"Working...\",\n        update_period: float = 0.1,\n    ) -> Iterable[ProgressType]:\n        \"\"\"Track progress by iterating over a sequence.\n", "stderr": "", "exit_code": 0}
4run_command
{
 "command": "grep -n \"def start\" rich/progress.py"
}
{"status": "ok", "stdout": "988: def started(self) -> bool:\n1168: def start(self) -> None:\n1387: def start_task(self, task_id: TaskID) -> None:\n", "stderr":
full
{"status": "ok", "stdout": "988:    def started(self) -> bool:\n1168:    def start(self) -> None:\n1387:    def start_task(self, task_id: TaskID) -> None:\n", "stderr": "", "exit_code": 0}
5run_command
{
 "command": "sed -n '1168,1172p' rich/progress.py"
}
{"status": "ok", "stdout": " def start(self) -> None:\n \"\"\"Start the progress display.\"\"\"\n if not self.disable:\n self.live.start(refresh=True)\n\n", "st
full
{"status": "ok", "stdout": "    def start(self) -> None:\n        \"\"\"Start the progress display.\"\"\"\n        if not self.disable:\n            self.live.start(refresh=True)\n\n", "stderr": "", "exit_code": 0}
6edit_file
{
 "filepath": "rich/progress.py",
 "new_string": "    def stop(self) -> None:\n        \\\"\\\"\\\"Stop the progress display.\\\"\\\"\\\"\n        self.live.stop()\n        if not self.disable and not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()",
 "old_string": "    def stop(self) -> None:\n        \\\"\\\"\\\"Stop the progress display.\\\"\\\"\\\"\n        self.live.stop()\n        if not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()"
}
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and
full
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context."}
7run_command
{
 "command": "sed -n '1173,1178p' rich/progress.py"
}
{"status": "ok", "stdout": " def stop(self) -> None:\n \"\"\"Stop the progress display.\"\"\"\n self.live.stop()\n if not self.console.is_interactive and not se
full
{"status": "ok", "stdout": "    def stop(self) -> None:\n        \"\"\"Stop the progress display.\"\"\"\n        self.live.stop()\n        if not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()\n\n", "stderr": "", "exit_code": 0}
8edit_file
{
 "filepath": "rich/progress.py",
 "new_string": "    def stop(self) -> None:\n        \\\"\\\"\\\"Stop the progress display.\\\"\\\"\\\"\n        self.live.stop()\n        if not self.disable and not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()",
 "old_string": "    def stop(self) -> None:\n        \\\"\\\"\\\"Stop the progress display.\\\"\\\"\\\"\n        self.live.stop()\n        if not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()"
}
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and
full
{"status": "error", "error_type": "FileEditError", "error_message": "Failed to replace: old_string not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context."}
9run_command
{
 "command": "cat -A rich/progress.py | sed -n '1173,1178p'"
}
{"status": "ok", "stdout": " def stop(self) -> None:$\n \"\"\"Stop the progress display.\"\"\"$\n self.live.stop()$\n if not self.console.is_interactive and not
full
{"status": "ok", "stdout": "    def stop(self) -> None:$\n        \"\"\"Stop the progress display.\"\"\"$\n        self.live.stop()$\n        if not self.console.is_interactive and not self.console.is_jupyter:$\n            self.console.print()$\n$\n", "stderr": "", "exit_code": 0}
10edit_file
{
 "filepath": "rich/progress.py",
 "new_string": "    def stop(self) -> None:\n        \"\"\"Stop the progress display.\"\"\"\n        self.live.stop()\n        if not self.disable and not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()",
 "old_string": "    def stop(self) -> None:\n        \"\"\"Stop the progress display.\"\"\"\n        self.live.stop()\n        if not self.console.is_interactive and not self.console.is_jupyter:\n            self.console.print()"
}
{"status": "ok", "filepath": "rich/progress.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/progress.py\n+++ b/rich/progress.py\n@@ -1173,7 +117
full
{"status": "ok", "filepath": "rich/progress.py", "occurrences": 1, "strategy": "exact", "diff": "--- a/rich/progress.py\n+++ b/rich/progress.py\n@@ -1173,7 +1173,7 @@\n     def stop(self) -> None:\n         \"\"\"Stop the progress display.\"\"\"\n         self.live.stop()\n-        if not self.console.is_interactive and not self.console.is_jupyter:\n+        if not self.disable and not self.console.is_interactive and not self.console.is_jupyter:\n             self.console.print()\n \n     def __enter__(self) -> Self:\n", "is_truncated": false}
11run_command
{
 "command": "python3 -c \"from rich.progress import Progress; from rich.console import Console; import io; buf = io.StringIO(); console = Console(file=buf); p = Progress(console=console, disable=True); p.start(); p.stop(); print(f'Output: {repr(buf.getvalue())}')\""
}
{"status": "ok", "stdout": "Output: ''\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "Output: ''\n", "stderr": "", "exit_code": 0}
12run_command
{
 "command": "python3 -c \"from rich.progress import Progress; from rich.console import Console; import io; buf = io.StringIO(); console = Console(file=buf, force_terminal=False); p = Progress(console=console, disable=False); p.start(); p.stop(); print(f'Output: {repr(buf.getvalue())}')\""
}
{"status": "ok", "stdout": "Output: '\\n'\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "Output: '\\n'\n", "stderr": "", "exit_code": 0}
13run_command
{
 "command": "cd /workspace && git status --short && git diff --stat"
}
{"status": "ok", "stdout": " M rich/progress.py\n rich/progress.py | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": " M rich/progress.py\n rich/progress.py | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n", "stderr": "", "exit_code": 0}
14run_command
{
 "command": "python3 -c \"import rich.progress\""
}
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
full
{"status": "ok", "stdout": "", "stderr": "", "exit_code": 0}
15submit_patch
{}
{"status": "ok", "patch_size": 521, "files_changed": 1}
full
{"status": "ok", "patch_size": 521, "files_changed": 1}

Patch

diff --git a/rich/progress.py b/rich/progress.py
index 421e1411..756b749d 100644
--- a/rich/progress.py
+++ b/rich/progress.py
@@ -1173,7 +1173,7 @@ class Progress(JupyterMixin):
     def stop(self) -> None:
         """Stop the progress display."""
         self.live.stop()
-        if not self.console.is_interactive and not self.console.is_jupyter:
+        if not self.disable and not self.console.is_interactive and not self.console.is_jupyter:
             self.console.print()
 
     def __enter__(self) -> Self:

Test output

show
.......................................                                  [100%]
39 passed in 0.55s