Message343614
> 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 |
|
Date |
User |
Action |
Args |
2019-05-27 11:14:14 | svenevs | set | recipients:
+ svenevs, benhoyt, paul.j3, charlie.proctor, rrt |
2019-05-27 11:14:14 | svenevs | set | messageid: <1558955654.89.0.502593267799.issue28609@roundup.psfhosted.org> |
2019-05-27 11:14:14 | svenevs | link | issue28609 messages |
2019-05-27 11:14:14 | svenevs | create | |
|