resolved RESOLVED PASS · 9 tool calls · 41 s · Textualize/rich
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 | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "find rich -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} |
| 2 | run_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} |
| 3 | run_command | {
"command": "sed -n '1170,1200p' rich/progress.py"
} | {"status": "ok", "stdout": " if not self.disable:\n self.live.start(refresh=True)\n\n def stop(self) -> None:\n \"\"\"Stop the progress display.\"\"\"\n self.lifull{"status": "ok", "stdout": " if not self.disable:\n self.live.start(refresh=True)\n\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 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} |
| 4 | run_command | {
"command": "grep -n \"self.disable\" rich/progress.py | head -20"
} | {"status": "ok", "stdout": "1096: self.disable = disable\n1170: if not self.disable:\n1548: if not self.disable and self.live.is_started:\n", "stderr": "", "exifull{"status": "ok", "stdout": "1096: self.disable = disable\n1170: if not self.disable:\n1548: if not self.disable and self.live.is_started:\n", "stderr": "", "exit_code": 0} |
| 5 | edit_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 andfull{"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."} |
| 6 | run_command | {
"command": "sed -n '1173,1180p' 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 sefull{"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", "stderr": "", "exit_code": 0} |
| 7 | edit_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 andfull{"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."} |
| 8 | run_command | {
"command": "cat -A rich/progress.py | sed -n '1173,1180p'"
} | {"status": "ok", "stdout": " def stop(self) -> None:$\n \"\"\"Stop the progress display.\"\"\"$\n self.live.stop()$\n if not self.console.is_interactive and notfull{"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", "stderr": "", "exit_code": 0} |
| 9 | edit_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 +117full{"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} |
| 10 | submit_patch | {} | {"status": "ok", "patch_size": 521, "files_changed": 1}full{"status": "ok", "patch_size": 521, "files_changed": 1} |
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:
....................................... [100%] 39 passed in 0.55s