Message410241
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).
https://bugs.python.org/issue9351
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
https://bugs.python.org/issue45235
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:16 | paul.j3 | set | recipients:
+ paul.j3, Lucas Cimon |
2022-01-10 18:55:16 | paul.j3 | set | messageid: <1641840916.08.0.630207679153.issue46101@roundup.psfhosted.org> |
2022-01-10 18:55:16 | paul.j3 | link | issue46101 messages |
2022-01-10 18:55:15 | paul.j3 | create | |
|