Skip to content

Conversation

@jkunimune
Copy link
Contributor

@jkunimune jkunimune commented May 26, 2024

It is currently stated that calling ArgumentParser.error() exits with a code of 2. However, it is not explicitly stated that this method is used in ArgumentParser.parse_args() when the arguments are invalid. Adding a note about the exit code to the exit_on_error argument of the ArgumentParser constructor makes this relationship explicit, and also makes this piece of information easier to notice.


📚 Documentation preview 📚: https://cpython-previews--119568.org.readthedocs.build/

It is currently stated that calling `ArgumentParser.error()` exits with a code of 2.  However, it is not explicitly stated that this method is used in `ArgumentParser.parse_args()` when the arguments are invalid.  Adding a note about the exit code to the `exit_on_error` argument of the `ArgumentParser` constructor makes this relationship explicit, and also makes this piece of information easier to notice.
@serhiy-storchaka
Copy link
Member

@savannahostrowski, this may be related to one of your recent changes. I am not sure that it is worth to repeat "print sys.stderr" here, but we should not create a new ambiguity.

@savannahostrowski
Copy link
Member

For consistency's sake, it's probably worth having the same phrasing here as well.

Co-authored-by: Savannah Ostrowski <[email protected]>
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.

LGTM, thank you!

@serhiy-storchaka serhiy-storchaka merged commit 3b87fb7 into python:main Oct 10, 2024
30 checks passed
@miss-islington-app
Copy link

Thanks @jkunimune for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2024
(cherry picked from commit 3b87fb7)

Co-authored-by: Justin Kunimune <[email protected]>
Co-authored-by: Savannah Ostrowski <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Oct 10, 2024

GH-125274 is a backport of this pull request to the 3.13 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 10, 2024
(cherry picked from commit 3b87fb7)

Co-authored-by: Justin Kunimune <[email protected]>
Co-authored-by: Savannah Ostrowski <[email protected]>
@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 10, 2024
@bedevere-app
Copy link

bedevere-app bot commented Oct 10, 2024

GH-125275 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Oct 10, 2024
serhiy-storchaka pushed a commit that referenced this pull request Oct 10, 2024
(cherry picked from commit 3b87fb7)

Co-authored-by: Justin Kunimune <[email protected]>
Co-authored-by: Savannah Ostrowski <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request Oct 10, 2024
(cherry picked from commit 3b87fb7)

Co-authored-by: Justin Kunimune <[email protected]>
Co-authored-by: Savannah Ostrowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants