New submission from Eric Pederson <[email protected]>:
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 <[email protected]>
<https://bugs.python.org/issue41592>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com