gh-86463: Fix default prog in subparsers if usage is used in the main parser (GH-125891)

The usage parameter of argparse.ArgumentParser no longer
affects the default value of the prog parameter in subparsers.

Previously the full custom usage of the main parser was used as
the prog prefix in subparsers.
This commit is contained in:
Serhiy Storchaka 2024-11-22 17:29:33 +02:00 committed by GitHub
parent 46f8a7bbdb
commit 0cb4d6c654
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 60 additions and 5 deletions

View file

@ -1889,7 +1889,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
formatter = self._get_formatter()
positionals = self._get_positional_actions()
groups = self._mutually_exclusive_groups
formatter.add_usage(self.usage, positionals, groups, '')
formatter.add_usage(None, positionals, groups, '')
kwargs['prog'] = formatter.format_help().strip()
# create the parsers action and add it to the positionals list