Skip to content

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

Open
mayuriphad wants to merge 1 commit into
lebrice:masterfrom
mayuriphad:fix/96-required-list-default-none-help
Open

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

Conversation

@mayuriphad

Copy link
Copy Markdown

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 lebrice#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.

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

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

2 participants