Skip to content

Commit 2ac39cb

Browse files
committed
gh-139736: Fix argparse indentation overshoot
When calculating the --help indentation, strip colors before counting the action length
1 parent 5a77f02 commit 2ac39cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def add_argument(self, action):
280280
if action.help is not SUPPRESS:
281281

282282
# find all invocations
283-
get_invocation = self._format_action_invocation
283+
get_invocation = lambda x: self._decolor(self._format_action_invocation(x))
284284
invocation_lengths = [len(get_invocation(action)) + self._current_indent]
285285
for subaction in self._iter_indented_subactions(action):
286286
invocation_lengths.append(len(get_invocation(subaction)) + self._current_indent)

0 commit comments

Comments
 (0)