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
Ensure --fail-on always returns a non-zero exit code when issue is matched #4713
Conversation
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.
Thank you for the changes, thjis look reasonable ! Could you add integration tests for this, please ? I'm thinking of something like:
@pytest.mark.parametrize("args,expected", [["fail-under", 0], ...])
def test_exit_code(args, expected):
with pytest.raises(SystemExit as e:
with patch("sys.argv", ["pylint", "tests/functional/...",] + args):
...
@Pierre-Sassoulas I've added some tests and I think what I've done works (the tests implement the correct behaviour, fail without the functionality patch and pass with the functionality patch) but if you have any suggestions for how to refine the structure of the tests or change where they should be located then please let me know. |
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 jobs, the tests are on point, I don't see any forgotten use cases, but if they exists it will be really easy to add them later on. I think this fix the issues you linked, we're not going to add an option for failing on information messages, it makes more sense has the default behavior. Do yo agree ?
I'm putting this in 2.10 because it'll feel like a breaking change is a pipeline start to fail because there were informational messages. Could you also add an explaining text in 2.10's what's new, please ? |
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
for more information, see https://pre-commit.ci
So I understand there is a need for caution around changes that it may change the behaviour of pipeline. However in order to have a pipeline that is currently succeeding become failing because of this patch, I think the following conditions would need to be met:
So this means that although a developer has explicitly set I would suggest that this should just be treated as a bug in the implementation of
can currently return a zero exit code even when a specified (info) message is detected. In which case I don't think that this would need to wait for 2.10. Does that sound reasonable to you or have I missed something? |
Ho, I did not notice the |
I'm sorry but I don't think I understand your last comment. Suppose we were to merge this PR exactly as it is right now into 2.9.4, what exactly is "the exit code change" that you are proposing could be done separately / later for 2.10? |
Sorry for being unclear. Considering that we now have 3 conditions:
I'd want to remove that last condition regarding the |
Ok, I think I understand now. In which case I suggest that the right thing to do is to merge this PR into 2.9.4 as a bug fix to make the implementation of |
Steps
doc/whatsnew/<current release.rst>
.Description
This fixes a bug in which pylint can still return a zero exit code when using --fail-on even if the specified issue occurs when the issues matched are all of info type.
Without this patch, running:
pylint --fail-on=useless-suppression a.py
whena.py
contains:returns exit code 0 despite matching the useless-suppression (info) issue.
Type of Changes
Related Issue
This is related to Issue #4296 and #3363. However although it will provides some other options for these issues, I don't think it will fully resolve them.