-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix inconsistent argument exit code when argparse exit with its own error code #7931
Fix inconsistent argument exit code when argparse exit with its own error code #7931
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Nice catch, we indeed missed that argparse could exit with its own exit code and the inconsistency with pylint's error codes. I think we should use -1 because it's the only way our bit encoded error code can be extended to 64 if required. Thoughts @DanielNoord ?
48b1e87
to
ce57811
Compare
|
This comment has been minimized.
This comment has been minimized.
You're right let's keep it as 32, I wasn't up to date on this aspect of the code sorry. |
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.
Could you fix the tests (there's some other test that is somewhat fragile you'll need to add the new file to it) and add a changelog entry please ?
Returning 2 here is confusing as it doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes
…t in a config file This is confusing behaviour. The output is: ``` usage: pylint [options] pylint: error: ambiguous option: --no could match --notes, --notes-rgx, --no-docstring-rgx ``` The exit code is 2 which doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes
…t in a config file
ce57811
to
b71f6ad
Compare
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.
Great job 👌
Pull Request Test Coverage Report for Build 3699121501
💛 - Coveralls |
…rror code (#7931) Returning 2 here is confusing as it doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes * pylint: use exit code 32 when invalid arguments are passed * pylint: add failing test when ambiguous abbreviated parameters are set in a config file This is confusing behaviour. The output is: ``` usage: pylint [options] pylint: error: ambiguous option: --no could match --notes, --notes-rgx, --no-docstring-rgx ``` The exit code is 2 which doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes * pylint: use exit code 32 when ambiguous abbreviated parameters are set in a config file Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> (cherry picked from commit 62232b3)
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 244e1cf |
…rror code (#7931) (#7943) Returning 2 here is confusing as it doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes * pylint: use exit code 32 when invalid arguments are passed * pylint: add failing test when ambiguous abbreviated parameters are set in a config file This is confusing behaviour. The output is: ``` usage: pylint [options] pylint: error: ambiguous option: --no could match --notes, --notes-rgx, --no-docstring-rgx ``` The exit code is 2 which doesn't match the documentation: https://pylint.pycqa.org/en/latest/user_guide/usage/run.html#exit-codes * pylint: use exit code 32 when ambiguous abbreviated parameters are set in a config file Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> (cherry picked from commit 62232b3) Co-authored-by: David Lawson <dmrlawson@gmail.com>
Type of Changes
Description
We were bitten by this causing us to think that pylint was completing successfully when in fact a typo in a configuration file was causing argparse to exit with exit code 2. This didn't happen in older versions of pylint for whatever reason. The documentation for pylint suggests that this means "error message issued" but that pylint executed properly when this is not the case.
It feels a bit clumsy to just add in
try..except
, but on the other hand it's perhaps unexpected that argparse will raise aSystemExit
. I'm open to any suggestions to improve this.