gh-157127: Reword the argparse mutually exclusive group error message - #157134
gh-157127: Reword the argparse mutually exclusive group error message#157134lazerg wants to merge 2 commits into
Conversation
…usive group error
Documentation build overview
10 files changed ·
|
picnixz
left a comment
There was a problem hiding this comment.
I suggest to reweite the error message as follows: "one of the following arguments is required: arg1, arg2, arg3".
Otherwise could we have some examples of what other CLIs in other packages format such errors (if any?) it would be good to take inspiration from them when possible
|
@picnixz Reworded in 3f7606e: It now matches the error argparse raises a few lines above for plain required arguments, For the other question, here is how three CLIs I checked format it:
All three put the names at the end and keep a visible separator between them. Brackets, pipes or commas, but never a bare space. The new message follows that. |
When a required mutually exclusive group is not satisfied, argparse joins the
argument names with a plain space:
With a positional in the group this reads as broken grammar, since nothing
separates one name from the next.
The error for missing required arguments a few lines above in
_parse_known_args()puts its names at the end of the sentence and joins themwith
', '. This makes the mutually exclusive group error do the same:The doc example and the three affected test assertions are updated to match.
Fixes #157127