Message379856
When using a custom type in add_argument(), the error message on an incorrect value uses repr instead of str, which looks ugly.
Example code:
login2account = {
c.account.login: c.account for c in self.admin.get_accounts()
}
action_add_parser.add_argument(
"--user",
dest="user",
type=lambda x: login2account.get(x, x),
choices=list(login2account.values()),
help="Login name of the user",
)
When using an unknown user, the output is something alike:
action add: error: argument --assignee: invalid choice: karen (choose from <Account(login=john)>, <Account(login=peter)>)
The culprit is the following line in lib.argparse._check_value():
args = {'value': value,
'choices': ', '.join(map(repr, action.choices))}
Which should be the following for prettier output:
args = {'value': value,
'choices': ', '.join(map(str, action.choices))} |
|
| Date |
User |
Action |
Args |
| 2020-10-29 07:45:26 | avdwoude | set | recipients:
+ avdwoude |
| 2020-10-29 07:45:26 | avdwoude | set | messageid: <1603957526.8.0.0927596859344.issue42191@roundup.psfhosted.org> |
| 2020-10-29 07:45:26 | avdwoude | link | issue42191 messages |
| 2020-10-29 07:45:26 | avdwoude | create | |
|