Skip to content

AI junk - #3804

Closed
Manny7717 wants to merge 2 commits into
pallets:mainfrom
Manny7717:fix/usage-hyphen-wrapping
Closed

AI junk#3804
Manny7717 wants to merge 2 commits into
pallets:mainfrom
Manny7717:fix/usage-hyphen-wrapping

Conversation

@Manny7717

Copy link
Copy Markdown

What

HelpFormatter.write_usage() wraps the argument string with wrap_text, which breaks long lines at hyphens by default. Usage lines for commands with many hyphenated options were rendered mid-option, e.g. at width 65:

Usage: program --output-file-path --max-retry-count --disable-
               cache-mode --config-file-location --verbose-
               logging-mode ...

Fixes #3362.

Change

  • wrap_text gains a break_on_hyphens parameter (default True, so write_text and other callers are unchanged).
  • write_usage wraps usage arguments with break_on_hyphens=False, so wrapping happens on spaces only and options stay intact.

Tests

  • New test_write_usage_does_not_break_options_at_hyphens with the issue's repro (10 hyphenated options at width 65): options remain intact and no line ends with a dangling -. Fails on the previous implementation (verified) and passes with the fix.
  • Full suite: 1992 passed, 24 skipped, 1 xfailed. ruff + mypy clean.

Manny7717 added 2 commits August 28, 2026 14:00
HelpFormatter.write_usage() passed the argument string to wrap_text,
which breaks long lines at hyphens by default. Usage lines for
commands with many hyphenated options were therefore split mid-option
(e.g. --disable-/cache-mode). Wrap usage arguments with
break_on_hyphens=False so options stay intact, adding a matching
parameter to wrap_text (default unchanged for other callers).
Closes pallets#3362
@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Aug 28, 2026
@davidism davidism added the rejected AI Contribution rejected because of its untrustworthy AI origin label Aug 28, 2026
@davidism davidism changed the title fix: wrap usage lines on spaces, not mid-option at hyphens AI junk Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected AI Contribution 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