Skip to content

AI spam#3518

Closed
thakoreh wants to merge 1 commit into
pallets:mainfrom
thakoreh:fix/help-formatter-break-on-hyphens
Closed

AI spam#3518
thakoreh wants to merge 1 commit into
pallets:mainfrom
thakoreh:fix/help-formatter-break-on-hyphens

Conversation

@thakoreh
Copy link
Copy Markdown

Problem

HelpFormatter.write_usage breaks long option names at hyphens when wrapping.

Root Cause

textwrap.TextWrapper defaults to break_on_hyphens=True. When options like --max-retry-count land near the line wrap boundary, Python textwrap splits them at the hyphen.

Fix

Set break_on_hyphens=False in wrap_text() since CLI options should never be split at hyphens. One-line change in src/click/formatting.py. 6 new tests.

Fixes #3362

TextWrapper defaults to break_on_hyphens=True, causing long option names
like --max-retry-count to be broken mid-hyphen at wrap boundaries.

Set break_on_hyphens=False in wrap_text() since CLI options should never
be split at hyphens.

6 new tests verifying options are not broken at hyphens.

Fixes pallets#3362
@davidism davidism closed this May 27, 2026
@davidism davidism changed the title Fix: HelpFormatter.write_usage breaks options at hyphens AI spam May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HelpFormatter.write_usage breaks options at a hyphen

2 participants