← eval7_submission_v1n

rich_3905

resolved RESOLVED PASS · 6 tool calls · 13 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 (7)

#ToolArgumentsResult
1run_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}
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 '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.li
full
{"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}
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 '1160,1175p' rich/progress.py"
}
{"status": "ok", "stdout": " @property\n def finished(self) -> bool:\n \"\"\"Check if all tasks have been completed.\"\"\"\n with self._lock:\n if not self._tas
full
{"status": "ok", "stdout": "    @property\n    def finished(self) -> bool:\n        \"\"\"Check if all tasks have been completed.\"\"\"\n        with self._lock:\n            if not self._tasks:\n                return True\n            return all(task.finished for task in self._tasks.values())\n\n    def start(self) -> None:\n        \"\"\"Start the progress display.\"\"\"\n        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", "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": "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}
7submit_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.53s