GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 🐛 fix(help): skip the default suffix when the help already used %(default)s by abhishekcpp007 · Pull Request #405 · tox-dev/sphinx-argparse-cli

Conversation

@abhishekcpp007

@abhishekcpp007 abhishekcpp007 commented Nov 11, 2026

Copy link
Copy Markdown

Since #355, _mk_option_line expands %(default)s in the help text first and only then checks whether the text already mentions a default. Once the placeholder has become its value, the word "default" is usually gone, so the extension appends its own (default: ...) and the value shows up twice.

parser.add_argument("--format", default="text", help="output format [%(default)s]")
parser.add_argument("--jobs", type=int, default=4, help="run %(default)s jobs in parallel")

1.24.2, text builder:

* **"--format"** "FORMAT" - output format [text] (default: "text")
* **"--jobs"** "JOBS" - run 4 jobs in parallel (default: "4")

--help prints output format [text] and run 4 jobs in parallel, which is what the page should say too. #355's own message says pages that already spell out the default should lose the duplicate; the existing test only passed because its help happens to contain the literal word (count (default: %(default)s)).

argparse's ArgumentDefaultsHelpFormatter makes this decision on the raw help ('%(default)' not in action.help), so the condition now checks the raw help as well as the expanded text.

roots/test-help-format-specifiers/parser.py gains --fmt with help="format [%(default)s]" and the expected output in test_help_format_specifiers shows it without a suffix. Changelog fragment included.

Verified in a python:3.12 container with the test dependency group:

  • this branch: 75 passed
  • the updated test against main's src: test_help_format_specifiers fails with the duplicated (default: "text")

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
abhishekcpp007 and others added 2 commits November 11, 2026 22:54
@abhishekcpp007 @Abhishekethar
🐛 fix(help): skip the default suffix when the help already used %(def…
c2289bd
…ault)s

tox-dev#355 started expanding %(default)s before deciding whether to append (default: ...), but the regex that looks for the word default ran on the expanded text. Once the placeholder became its value the word was usually gone, so the option got the default twice. argparse makes this call on the raw help, so check it there too.
@pre-commit-ci
[pre-commit.ci] auto fixes from pre-commit.com hooks
f764d6b
for more information, see https://pre-commit.ci

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@abhishekcpp007
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.