diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-09-30 01:05:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-30 01:05:51 (GMT) |
commit | 8d3a0fecbe2edb69cf66db82f1c59601aac94651 (patch) | |
tree | 64a9053aead9581eb7551e896ebec19dd173fed3 /Lib/argparse.py | |
parent | 67aa68f1b4f0205fb15b03032cb0452d9c5545f0 (diff) | |
download | cpython-8d3a0fecbe2edb69cf66db82f1c59601aac94651.zip cpython-8d3a0fecbe2edb69cf66db82f1c59601aac94651.tar.gz cpython-8d3a0fecbe2edb69cf66db82f1c59601aac94651.tar.bz2 |
[3.13] GH-87041: Fix incorrect indentation in argparse help (GH-124230) (#124373)
GH-87041: Fix incorrect indentation in argparse help (GH-124230)
In case of usage a long command along with max_help_position more than
the length of the command, the command's help was incorrectly started
on the new line.
(cherry picked from commit 7ee99217345af3010bf05b1f5241c661a5e0ea9b)
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Co-authored-by: Pavel Ditenbir <pavel.ditenbir@gmail.com>
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r-- | Lib/argparse.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index e670962..b0f9656 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -261,13 +261,12 @@ class HelpFormatter(object): # find all invocations get_invocation = self._format_action_invocation - invocations = [get_invocation(action)] + invocation_lengths = [len(get_invocation(action)) + self._current_indent] for subaction in self._iter_indented_subactions(action): - invocations.append(get_invocation(subaction)) + invocation_lengths.append(len(get_invocation(subaction)) + self._current_indent) # update the maximum item length - invocation_length = max(map(len, invocations)) - action_length = invocation_length + self._current_indent + action_length = max(invocation_lengths) self._action_max_length = max(self._action_max_length, action_length) |