From 3052bf8a915729937b56a039231e111dfa0eebb7 Mon Sep 17 00:00:00 2001 From: Mateeh Ullah Date: Sun, 25 Oct 2026 18:00:46 +0500 Subject: [PATCH 1/2] fix: avoid leading blank line in WrappedJoin (#705) --- fire/formatting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fire/formatting.py b/fire/formatting.py index 68484c279..e5daf6849 100644 --- a/fire/formatting.py +++ b/fire/formatting.py @@ -50,13 +50,15 @@ def WrappedJoin(items, separator=' | ', width=80): if len(current_line) + len(item) <= width: current_line += item else: - lines.append(current_line.rstrip()) + if current_line: + lines.append(current_line.rstrip()) current_line = item else: if len(current_line) + len(item) + len(separator) <= width: current_line += item + separator else: - lines.append(current_line.rstrip()) + if current_line: + lines.append(current_line.rstrip()) current_line = item + separator lines.append(current_line) From 582b1d4d343bcb4930ce79583692d1bf216b7b29 Mon Sep 17 00:00:00 2001 From: Mateeh Ullah Date: Sun, 25 Oct 2026 18:00:49 +0500 Subject: [PATCH 2/2] fix: avoid leading blank line in WrappedJoin (#705) --- fire/formatting_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fire/formatting_test.py b/fire/formatting_test.py index e0f6699d2..d1273fc58 100644 --- a/fire/formatting_test.py +++ b/fire/formatting_test.py @@ -49,6 +49,15 @@ def test_wrap_multiple_items(self): 'chicken |', 'cheese'], lines) + def test_wrap_oversized_first_item(self): + self.assertEqual(['long_command'], + formatting.WrappedJoin(['long_command'], width=5)) + self.assertEqual(['first |', 'next'], + formatting.WrappedJoin(['first', 'next'], width=5)) + + def test_wrap_empty_items(self): + self.assertEqual([''], formatting.WrappedJoin([], width=5)) + def test_ellipsis_truncate(self): text = 'This is a string' truncated_text = formatting.EllipsisTruncate(