Stephen McDowell <svenevs....@gmail.com> added the comment:
> For optionals, `required` is set by the programmer. But for positionals it > is set with: ... > So for '?' argument, required is False. But for '*', it must also have a > 'default' parameter (not just the default None). > So the proposed patch is overriding the 'required' value that was set during > 'add_argument'. And issuing this error message is the main purpose of the > 'required' attribute. nargs='*' being marked as `required` is incorrect though, isn't it? I was also very confused by this behavior, the only reason I found this bug was to search before opening new, and had a patch prepared that is nearly identical to the one here. 1. It's really helpful to know about explicitly setting `default=None|[]` depending on use case. Would a docs PR briefly explaining at the bottom of the nargs [a] docs explaining how to change the error message via `default` be welcome? This is a slightly challenging problem to search for. 2. My understanding is the ultimate rejection of the patch is because it's bypassing the `required` attribute. So to fix this adequately, changing ? and * to not show up as required (when no `default` provided) should be done? [a] https://docs.python.org/3/library/argparse.html#nargs ---------- nosy: +svenevs _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue28609> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com