paul j3 <ajipa...@gmail.com> added the comment:
In the subparser example, it's the `build` subparser that puts '--overwritte' in the unrecognized list. That is then passed back to the main parser, which then issues the 'unrecognized' error, along with its own usage. The subparser is called with `parse_known_args` while the proposed patch is run in the `parse_args` method of the main parser. It doesn't have access to the subparser's arguments. So implementing the proposed matching will be much harder. For some types of error, such as type or choices, the subparser itself raises the error, with the appropriate usage. === https://bugs.python.org/issue42297 [argparse] Bad error message formatting when using custom usage text is another case where error messages produced by the subparser differ from messages produced by the main. In this case the unrecognized error usage message is clearer since it is produced by the main parser. === I didn't close this issue, but it does feel like an enhancement that's too big for the bug/issues forum. The proposed patch could be developed as a separate 'parser.parse_args_with_hints' method, and distributed as a pypi addition. During development and testing, the regular 'parser.parse_args()' does not need to be touched. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39106> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com