This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients Anthony Sottile, bethard, bskinn, eric.araujo, gregory.p.smith, memeplex, ned.deily, paul.j3, serhiy.storchaka, wolma
Date 2018-05-22.19:02:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I tried to use add_subparsers() with required=True and have found it not usable.

import argparse
parser = argparse.ArgumentParser(prog='PROG')
subparsers = parser.add_subparsers(required=True)
parser_a = subparsers.add_parser('a')
parser_b = subparsers.add_parser('b')

The result:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/", line 1745, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/home/serhiy/py/cpython/Lib/", line 1777, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/home/serhiy/py/cpython/Lib/", line 2012, in _parse_known_args
    ', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found

Seems that not only the default value should be changed, but the whole PR 3027 should be reverted.
Date User Action Args
2018-05-22 19:02:16serhiy.storchakasetrecipients: + serhiy.storchaka, gregory.p.smith, bethard, ned.deily, eric.araujo, memeplex, paul.j3, wolma, Anthony Sottile, bskinn
2018-05-22 19:02:16serhiy.storchakasetmessageid: <>
2018-05-22 19:02:16serhiy.storchakalinkissue33109 messages
2018-05-22 19:02:16serhiy.storchakacreate