-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-85935: Check for nargs=0 for positional arguments in argparse #124839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-85935: Check for nargs=0 for positional arguments in argparse #124839
Conversation
Raise ValueError in add_argument() if either explicit nargs=0 or action that does not consume arguments (like 'store_const' or 'store_true') is specified for positional argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, LGTM. I had one comment about whether we could be more actionable in the error message, but there may be existing style guidance around error messages that I don't know about, which makes my comment moot.
Misc/NEWS.d/next/Library/2024-10-01-13-11-53.gh-issue-85935.CTwJUy.rst
Outdated
Show resolved
Hide resolved
…wJUy.rst Co-authored-by: Savannah Ostrowski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review @savannahostrowski. I think that the error messages are in line with existing error messages and do not need to be too verbose. This is a task for documentation.
Raise ValueError in add_argument() if either explicit nargs=0 or action that does not consume arguments (like 'store_const' or 'store_true') is specified for positional argument.