Skip to content

AI junk - #3798

Closed
22elix3r wants to merge 1 commit into
pallets:mainfrom
22elix3r:fix/3362-usage-hyphen-break
Closed

AI junk#3798
22elix3r wants to merge 1 commit into
pallets:mainfrom
22elix3r:fix/3362-usage-hyphen-break

Conversation

@22elix3r

Copy link
Copy Markdown

Summary

HelpFormatter.write_usage wraps its argument string with wrap_text, which uses textwrap.TextWrapper's default break_on_hyphens=True. When a hyphenated option sits at the wrap width it is split mid-token, for example --max-retry-count becomes --max- on one line and retry-count on the next.

Related Issue

Fixes#3362

Changes Made

  • Add a break_on_hyphens argument to wrap_text (default True, so help body text is unchanged).
  • Pass break_on_hyphens=False from both wrapping branches of HelpFormatter.write_usage.
  • Changelog entry under 8.5.1.

Testing

  • pytest tests/test_formatting.py (40 passed)
  • pytest (1994 passed, 24 skipped, 1 xfailed)
  • ruff check / ruff format on the touched files

The new tests cover wrap_text itself, the issue's usage-line reproduction at width 65, and the long-prefix branch of write_usage.

Notes

Help text wrapping is unchanged. A token that is itself wider than the line can still be broken by break_long_words.

HelpFormatter.write_usage wrapped arguments with textwrap's default
break_on_hyphens=True, so option names like --max-retry-count were
split across lines. Thread break_on_hyphens through wrap_text and
disable it for usage arguments.
Fixespallets#3362
Signed-off-by: elix3r <157088510+22elix3r@users.noreply.github.com>

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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 Don't break hyphenated tokens in usage wrappingAI 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

3 participants

@22elix3r@davidism