Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into colored_defaults
  • Loading branch information
alexprengere authored Dec 12, 2025
commit 7698ac483d4b3e95b71dd6e230b32eb3aa6c60e5
27 changes: 15 additions & 12 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,18 +742,21 @@ def _get_help_string(self, action):
if help is None:
help = ''

if '%(default)' not in help:
if action.default is not SUPPRESS:
defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
if action.option_strings or action.nargs in defaulting_nargs:
t = self._theme
default_str = _(" (default: %(default)s)")
prefix, suffix = default_str.split("%(default)s")
help += (
f" {t.default}{prefix.lstrip()}{t.reset}"
f"%(default)s"
f"{t.default}{suffix}{t.reset}"
)
if (
'%(default)' not in help
and action.default is not SUPPRESS
and not action.required
):
defaulting_nargs = (OPTIONAL, ZERO_OR_MORE)
if action.option_strings or action.nargs in defaulting_nargs:
t = self._theme
default_str = _(" (default: %(default)s)")
prefix, suffix = default_str.split("%(default)s")
help += (
f" {t.default}{prefix.lstrip()}{t.reset}"
f"%(default)s"
f"{t.default}{suffix}{t.reset}"
)
return help


Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.