Skip to content

AI junk - #3796

Closed
arpansahu wants to merge 1 commit into
pallets:mainfrom
arpansahu:fix/help-usage-hyphen-wrap
Closed

AI junk#3796
arpansahu wants to merge 1 commit into
pallets:mainfrom
arpansahu:fix/help-usage-hyphen-wrap

Conversation

@arpansahu

Copy link
Copy Markdown

Problem

HelpFormatter.write_usage can wrap usage text at hyphens inside long option names. For example, --max-retry-count may be split as --max- followed by retry-count, producing usage output that looks like two separate tokens.

Closes#3362

Reproducer

f = click.HelpFormatter(width=65)
f.write_usage("program", "--enable-verbose-logging --output-file-path --max-retry-count")
# before: Usage: program ... --output-file-path --max-
# retry-count ...
# expected: Usage: program ... --output-file-path
# --max-retry-count ...

Fix

Allow wrap_text callers to disable hyphen breaks, and have write_usage do so for usage arguments. This preserves option/metavar tokens while keeping the existing wrapping behavior elsewhere.

Testing

Added test_help_formatter_write_usage_does_not_break_on_hyphens. Ran:

python -m pytest tests\test_formatting.py::test_help_formatter_write_usage_does_not_break_on_hyphens -q
python -m pytest tests\test_formatting.py -q
python -m pytest

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: arpan sahu <28574248+arpansahu@users.noreply.github.com>
@davidism

Copy link
Copy Markdown
Member

@davidismdavidism added the rejected AI Contribution rejected because of its untrustworthy AI origin label Aug 27, 2026
@davidismdavidism changed the title Fix usage wrapping at option hyphensAI junkAug 27, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected AIContribution rejected because of its untrustworthy AI origin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HelpFormatter.write_usage breaks options at a hyphen

2 participants

@arpansahu@davidism