[New-bugs-announce] [issue41592] Make _SubParsersAction public
Eric Pederson
report at bugs.python.org
Wed Aug 19 15:21:34 EDT 2020
New submission from Eric Pederson <ericacm at gmail.com>:
ArgumentParser.add_subparsers() returns a _SubParsersAction. This requires user code using type annotations to use a protected type which causes type checkers like PyCharm to complain. For example:
def add_subparser(name: str, subparser: _SubParsersAction, subparsers: dict) -> ArgumentParser:
parser = subparser.add_parser(name)
parser.add_argument('-v', '--verbose', action='store_true')
subparsers[name] = parser
return parser
You can't use plain Action because Action doesn't have the add_parser() method.
----------
components: Library (Lib)
messages: 375670
nosy: sourcedelica
priority: normal
severity: normal
status: open
title: Make _SubParsersAction public
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41592>
_______________________________________
More information about the New-bugs-announce
mailing list