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 paul.j3
Recipients Lucas Cimon, paul.j3
Date 2022-01-10.18:55:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
This patch should be rejected.

By using `common_opts_parser` as parent to both the main and subparsers, you have defined the same argument in both.

By a long standing patch, the value assigned in the subparser has precedence (whether it's the default or user supplied).
argparse set_defaults on subcommands should override top level set_defaults

Partial retraction of this override has been explored, but any changes are still up for debate
argparse does not preserve namespace with subparser defaults

The bottom line is that we should not try to define the same argument (or more specifically the same `dest`) in both main and subparsers.  Duplicate flags are ok.  

But resolving the conflicting values should be done after parsing.  Some users will want to give priority to the main parser's values, others to the subparser's.  Or their own defaults.  argparse cannot handle all cases cleanly.
Date User Action Args
2022-01-10 18:55:16paul.j3setrecipients: + paul.j3, Lucas Cimon
2022-01-10 18:55:16paul.j3setmessageid: <>
2022-01-10 18:55:16paul.j3linkissue46101 messages
2022-01-10 18:55:15paul.j3create