GH-130750: Restore quoting of choices in argparse error messages to match documentation and improve clarity#144983
Conversation
sobolevn
left a comment
There was a problem hiding this comment.
I support explicit quotes, because bar in Python is a variable name, 'bar' is a string. 👍
|
@serhiy-storchaka Mind taking a look at this one, since you were involved in the merge of the PR that changed this display? |
|
Looking how is this handled in other programs. On Linux: On FreeBSD: Both quote the invalid value, but do not quote the list of valid values. |
|
There are also plenty of command-line tools that do quote valid choices in error messages, so it's a mixed bag across the ecosystem, I think. My preference would be to restore the previous quoting behavior here. The PR that changed the display wasn't really about removing quotes; it was about fixing StrEnum, and the loss of quotes was an acknowledged side effect. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Well, argparce deviated enough from the original getopt.c, so we can not follow it in this particular detail.
|
Thanks @savannahostrowski for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
|
Sorry, @savannahostrowski, I could not cleanly backport this to |
|
Sorry, @savannahostrowski, I could not cleanly backport this to |
|
GH-149385 is a backport of this pull request to the 3.14 branch. |
|
GH-149386 is a backport of this pull request to the 3.13 branch. |
In 66b3922 (gh-117766), argparse was changed to use
str()instead ofrepr()when displaying choices in error messages. This was done to improve StrEnum display, but had the side effect of removing quotes from string choices, making error messages less clear and inconsistent with the documentation.