Skip to content

Don't show '(default: None)' for required arguments without a default - #370

Merged
lebrice merged 1 commit into
lebrice:masterfrom
mayuriphad:fix/96-required-list-default-none-help
Nov 4, 2026
Merged

lebrice merged 1 commit into
lebrice:masterfrom
mayuriphad:fix/96-required-list-default-none-help

Conversation

@mayuriphad

Copy link
Copy Markdown
Contributor

Fixes #96.

What & Why

\SimpleHelpFormatter\ inherits argparse's \ArgumentDefaultsHelpFormatter, which appends (default: None)\ to each option. A required field with no default showed a default it does not have. Required actions whose default is \None\ now skip that suffix. Optional arguments are unchanged.

Changes

  • \simple_parsing/help_formatter.py: in _get_help_string, required actions with \default is None\ bypass the defaults-appending base method.
  • \ est/test_help_required_default.py: regression test. Fails without the change, passes with it.
  • \ est/test_issue_48.py: its expected output pinned (default: None)\ for two required fields with no default, which is the behavior this issue reports as wrong. Updated the expectation; no other lines changed.

Test

  • Full suite: 7 failures remain. Each also fails on the base commit (I compared the failing-test lists with and without this change). The new regression test passes.
  • Ran on Windows, Python 3.12, with --benchmark-disable.

SimpleHelpFormatter inherits argparse's ArgumentDefaultsHelpFormatter,
which appends '(default: None)' to every option. A required field with no
default therefore claimed a default it does not have.

Skip the default suffix for required actions whose default is None.
Optional arguments are unchanged.

Updates test_issue_48, which pinned the old output for two required
fields, and adds a regression test.

Fixes #96
Copilot AI balanced review requested due to automatic review settings October 3, 2026 05:52

Copilot AI 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.

@mayuriphad

Copy link
Copy Markdown
Contributor Author

Hi, just a gentle ping on this PR. It's ready for review whenever you have time, and I'm happy to make any changes you'd like. Thanks!

@lebrice

lebrice commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @mayuriphad !

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the change removing misleading default annotations from required-argument help text.

No open issues 🎉

Review effort: Balanced

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.

Specifying help text on a field causes the help to indicate a default of None even if there is no default

3 participants