Skip to content

gh-119021: Fix subparsers' indentation in argparse module #119616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,7 @@ def _iter_indented_subactions(self, action):
except AttributeError:
pass
else:
self._indent()
yield from get_subactions()
self._dedent()

def _split_lines(self, text, width):
text = self._whitespace_matcher.sub(' ', text).strip()
Expand Down
23 changes: 11 additions & 12 deletions Lib/test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2447,9 +2447,9 @@ def test_parser_command_help(self):
positional arguments:
bar bar help
{1,2,3} command help
1 1 help
2 2 help
3 3 help
1 1 help
2 2 help
3 3 help

options:
-h, --help show this help message and exit
Expand Down Expand Up @@ -2552,10 +2552,9 @@ def test_alias_help(self):

commands:
COMMAND
1 (1alias1, 1alias2)
1 help
2 2 help
3 3 help
1 (1alias1, 1alias2) 1 help
2 2 help
3 3 help
"""))

# ============
Expand Down Expand Up @@ -4872,11 +4871,11 @@ class TestHelpSubparsersWithHelpOrdering(HelpTestCase):

positional arguments:
{a,b,c,d,e}
a a subcommand help
b b subcommand help
c c subcommand help
d d subcommand help
e e subcommand help
a a subcommand help
b b subcommand help
c c subcommand help
d d subcommand help
e e subcommand help

options:
-h, --help show this help message and exit
Expand Down
Loading