Skip to content

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 1, 2024

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.

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.
Copy link
Member

@savannahostrowski savannahostrowski left a 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.

Copy link
Member Author

@serhiy-storchaka serhiy-storchaka left a 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.

@serhiy-storchaka serhiy-storchaka merged commit 9944ad3 into python:main Oct 12, 2024
34 checks passed
@serhiy-storchaka serhiy-storchaka deleted the argparse-nargs-0-positional branch October 12, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants