Don't wrap usage lines in the middle of hyphenated option names - #3814
Open
MaxxxDong wants to merge 1 commit into
Open
Don't wrap usage lines in the middle of hyphenated option names#3814MaxxxDong wants to merge 1 commit into
MaxxxDong wants to merge 1 commit into
Conversation
write_usage used textwrap's default break_on_hyphens, so names like --max-retry-count were split across lines. Disable that for usage wrapping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HelpFormatter.write_usagewraps usage arguments withtextwrap.TextWrapper, which defaults tobreak_on_hyphens=True. Hyphenated option names such as--max-retry-countwere therefore split across lines:write_usagenow passesbreak_on_hyphens=Falseso wrapping only happens at spaces. Help-text wrapping is unchanged.Fixes #3362.
Test plan
HelpFormatter.write_usagebreaks options at a hyphen #3362 (width=65) asserts every option name is intact and no usage line ends with a hyphen.tests/test_formatting.py(38 tests) pass.ruff check/ruff formaton the touched files.