-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Note argparse exit code in documentation #119568
Conversation
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.
@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. |
For consistency's sake, it's probably worth having the same phrasing here as well. |
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.
LGTM, thank you!
Thanks @jkunimune for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
(cherry picked from commit 3b87fb7) Co-authored-by: Justin Kunimune <[email protected]> Co-authored-by: Savannah Ostrowski <[email protected]>
GH-125274 is a backport of this pull request to the 3.13 branch. |
(cherry picked from commit 3b87fb7) Co-authored-by: Justin Kunimune <[email protected]> Co-authored-by: Savannah Ostrowski <[email protected]>
GH-125275 is a backport of this pull request to the 3.12 branch. |
(cherry picked from commit 3b87fb7) Co-authored-by: Justin Kunimune <[email protected]> Co-authored-by: Savannah Ostrowski <[email protected]>
(cherry picked from commit 3b87fb7) Co-authored-by: Justin Kunimune <[email protected]> Co-authored-by: Savannah Ostrowski <[email protected]>
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 inArgumentParser.parse_args()
when the arguments are invalid. Adding a note about the exit code to theexit_on_error
argument of theArgumentParser
constructor makes this relationship explicit, and also makes this piece of information easier to notice.📚 Documentation preview 📚: https://cpython-previews--119568.org.readthedocs.build/