Content-Length: 349905 | pFad | https://github.com/python/cpython/pull/124839

BA gh-85935: Check for nargs=0 for positional arguments in argparse by serhiy-storchaka · Pull Request #124839 · python/cpython · GitHub
Skip to content

gh-85935: Check for nargs=0 for positional arguments in argparse#124839

Merged
serhiy-storchaka merged 4 commits intopython:mainfrom
serhiy-storchaka:argparse-nargs-0-positional
Oct 12, 2024
Merged

gh-85935: Check for nargs=0 for positional arguments in argparse#124839
serhiy-storchaka merged 4 commits intopython:mainfrom
serhiy-storchaka:argparse-nargs-0-positional

Conversation

@serhiy-storchaka
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread Lib/argparse.py
Comment thread Misc/NEWS.d/next/Library/2024-10-01-13-11-53.gh-issue-85935.CTwJUy.rst Outdated
…wJUy.rst

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
Copy link
Copy Markdown
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.

Comment thread Lib/argparse.py
@serhiy-storchaka serhiy-storchaka merged commit 9944ad3 into python:main Oct 12, 2024
@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









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/pull/124839

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy