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.

classification
Title: Add support to add existing parser to ArgumentParser.subparsers
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: borkivskyi, paul.j3, rhettinger
Priority: normal Keywords:

Created on 2020-12-11 14:06 by borkivskyi, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg382867 - (view) Author: Bohdan Borkivskyi (borkivskyi) Date: 2020-12-11 14:06
Currently, there is only a possibility to create empty parser as subparser - argparse.py, line 1122

The purpose of issue is to add support for existing parser to be added as subparser
msg382887 - (view) Author: paul j3 (paul.j3) * (Python triager) Date: 2020-12-11 20:05
An existing parser can be included in a new subparser via the 'parents' mechanism.  With that the _actions and groups of the parent are copied (by reference) to the new subparser.

There are some rough edges to the parents mechanism, but people have used it to add a common subset of arguments to all subparsers.
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86788
2020-12-11 20:05:09paul.j3setmessages: + msg382887
2020-12-11 15:09:15xtreaksetnosy: + rhettinger, paul.j3
2020-12-11 14:12:48borkivskyisetversions: + Python 3.10, - Python 3.9
2020-12-11 14:06:00borkivskyicreate