Message317325
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')
parser.parse_args([])
The result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/serhiy/py/cpython/Lib/argparse.py", line 1745, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/home/serhiy/py/cpython/Lib/argparse.py", line 1777, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/home/serhiy/py/cpython/Lib/argparse.py", 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:16 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gregory.p.smith, bethard, ned.deily, eric.araujo, memeplex, paul.j3, wolma, Anthony Sottile, bskinn |
2018-05-22 19:02:16 | serhiy.storchaka | set | messageid: <1527015736.29.0.682650639539.issue33109@psf.upfronthosting.co.za> |
2018-05-22 19:02:16 | serhiy.storchaka | link | issue33109 messages |
2018-05-22 19:02:16 | serhiy.storchaka | create | |
|