From cbbf18f5179f979860f467aa3c9e528f85c32d8d Mon Sep 17 00:00:00 2001 From: Im-Siyoun Date: Sun, 3 May 2026 22:22:34 +0900 Subject: [PATCH] Fix HelpFormatter.write_usage with empty args --- src/click/formatting.py | 2 +- tests/test_formatting.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/click/formatting.py b/src/click/formatting.py index 0b64f831b5..7b272c1b1a 100644 --- a/src/click/formatting.py +++ b/src/click/formatting.py @@ -63,7 +63,7 @@ def wrap_text( replace_whitespace=False, ) if not preserve_paragraphs: - return wrapper.fill(text) + return wrapper.fill(text) if text else initial_indent p: list[tuple[int, bool, str]] = [] buf: list[str] = [] diff --git a/tests/test_formatting.py b/tests/test_formatting.py index c74b53a3df..e1530c4d85 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -433,3 +433,10 @@ def test_help_formatter_write_text(): actual = formatter.getvalue() expected = " Lorem ipsum dolor sit amet,\n consectetur adipiscing elit\n" assert actual == expected + + +def test_help_formatter_write_usage_without_args(): + f = click.HelpFormatter() + f.write_usage("Program") + expected = "Usage: Program \n" + assert f.getvalue() == expected