Skip to content

Commit a7b0904

Browse files
committed
fix parser
1 parent 24069fb commit a7b0904

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Lib/argparse.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,17 +1259,16 @@ def add_parser(self, name, *, deprecated=False, **kwargs):
12591259
if alias in self._name_parser_map:
12601260
raise ValueError(f'conflicting subparser alias: {alias}')
12611261

1262-
# create a pseudo-action to hold the choice help
1263-
if 'help' in kwargs:
1264-
help = kwargs.pop('help')
1265-
choice_action = self._ChoicesPseudoAction(name, aliases, help)
1266-
self._choices_actions.append(choice_action)
1267-
else:
1268-
choice_action = None
1262+
# Handle help/description logic
1263+
help = kwargs.pop('help', None)
1264+
if 'description' not in kwargs and help is not None:
1265+
kwargs['description'] = help
12691266

1270-
# create the parser and add it to the map
1267+
# Create the parser and pseudo-action
12711268
parser = self._parser_class(**kwargs)
1272-
if choice_action is not None:
1269+
if help is not None:
1270+
choice_action = self._ChoicesPseudoAction(name, aliases, help)
1271+
self._choices_actions.append(choice_action)
12731272
parser._check_help(choice_action)
12741273
self._name_parser_map[name] = parser
12751274

0 commit comments

Comments
 (0)