From 75deb2a951597c737a5a2595cbd0b0182f9ee101 Mon Sep 17 00:00:00 2001 From: Tomer Yogev Date: Wed, 3 Dec 2025 23:32:48 +0200 Subject: [PATCH 1/3] Update progress.py Don't output extraneous blank line when progress display is disabled --- rich/progress.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rich/progress.py b/rich/progress.py index ef6ad60f08..7ce80187f7 100644 --- a/rich/progress.py +++ b/rich/progress.py @@ -1172,9 +1172,10 @@ def start(self) -> None: def stop(self) -> None: """Stop the progress display.""" - self.live.stop() - if not self.console.is_interactive and not self.console.is_jupyter: - self.console.print() + if not self.disable: + self.live.stop() + if not self.console.is_interactive and not self.console.is_jupyter: + self.console.print() def __enter__(self) -> Self: self.start() From 7c0a0ebdbbe37f4ebf0ee9850dc85954bd5f12e5 Mon Sep 17 00:00:00 2001 From: Tomer Yogev Date: Wed, 3 Dec 2025 23:41:44 +0200 Subject: [PATCH 2/3] Add test --- tests/test_progress.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_progress.py b/tests/test_progress.py index 0be683c3ea..20f426a4cd 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -565,6 +565,30 @@ def test_no_output_if_progress_is_disabled() -> None: assert result == expected +def test_no_output_if_progress_is_disabled_non_interactive() -> None: + console = Console( + file=io.StringIO(), + force_interactive=False, + width=60, + color_system="truecolor", + legacy_windows=False, + _environ={}, + ) + progress = Progress( + console=console, + disable=True, + ) + test = ["foo", "bar", "baz"] + expected_values = iter(test) + with progress: + for value in progress.track(test, description="test"): + assert value == next(expected_values) + result = console.file.getvalue() + print(repr(result)) + expected = "" + assert result == expected + + def test_open() -> None: console = Console( file=io.StringIO(), From 216563d25f7d4684e41695b967b6e9919780857f Mon Sep 17 00:00:00 2001 From: Tomer Yogev Date: Wed, 3 Dec 2025 23:52:14 +0200 Subject: [PATCH 3/3] Add to changelog --- CHANGELOG.md | 6 ++++++ CONTRIBUTORS.md | 1 + 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53205666f..971447aa17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Fixed extraneous blank line on non-interactive disabled `Progress` https://github.com/Textualize/rich/pull/3905 + ## [14.2.0] - 2025-10-09 ### Changed diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4b04786b9c..090d4e5ab5 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -80,6 +80,7 @@ The following people have contributed to the development of Rich: - [Motahhar Mokfi](https://github.com/motahhar) - [Tomer Shalev](https://github.com/tomers) - [Serkan UYSAL](https://github.com/uysalserkan) +- [Tomer Yogev](https://github.com/TomerYogev) - [Zhe Huang](https://github.com/onlyacat) - [Adrian Zuber](https://github.com/xadrianzetx) - [Ke Sun](https://github.com/ksun212)