Skip to content
Closed
Changes from 3 commits
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
6 changes: 5 additions & 1 deletion Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ def _expand_help(self, action):
if params.get('choices') is not None:
choices_str = ', '.join([str(c) for c in params['choices']])
params['choices'] = choices_str
return self._get_help_string(action) % params
expanded_help = self._get_help_string(action)
for param, value in params.items():
if f'%({param})s' in expanded_help:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this conditional is redundant, right? Doesn't replace() handle validating that the string is contained by expanded_help?

expanded_help = expanded_help.replace(f'%({param})s', str(value))
return expanded_help.replace('%%','%')

def _iter_indented_subactions(self, action):
try:
Expand Down