Skip to content
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

pylint's return code is still 0 when analysed code contains useless-suppressions #4296

Closed
MarkCBell opened this issue Apr 5, 2021 · 4 comments · Fixed by #4713
Closed

pylint's return code is still 0 when analysed code contains useless-suppressions #4296

MarkCBell opened this issue Apr 5, 2021 · 4 comments · Fixed by #4713
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors Help wanted 🙏 Outside help would be appreciated, good for new contributors
Milestone

Comments

@MarkCBell
Copy link
Contributor

Steps to reproduce

Given a file a.py:

def foo(x):  # pylint: disable=unused-argument
    return x+1

Current behavior

Result of pylint a.py --disable=all --enable=useless-suppression:

a.py:1:0: I0021: Useless suppression of 'unused-argument' (useless-suppression)

however the return code of this is command 0. This makes it much more difficult create CI/CD pipelines that check whether there are unneeded suppressions, for example.

This appears to be because of the fact that even though a message is added to the reporter, the MSG_TYPES_STATUS of info messages is 0. Hence when this message is parsed, msg_status is or'ed with 0 and so the return code of the command is still 0.

Expected behavior

The return code should be non-zero since a check which was enabled has failed.

There are a number of different ways to achieve this including:

  1. Change MSG_TYPES_STATUS['I'] to a non-zero number so that raising any info messages results in a non-zero exit code
  2. Change the useless-suppression from type info to be type warning

pylint --version output

Result of pylint --version output:

pylint 2.7.4
astroid 2.5.2
Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0]
@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 Good first issue Friendly and approachable by new contributors Help wanted 🙏 Outside help would be appreciated, good for new contributors labels Apr 5, 2021
@dbaty
Copy link
Contributor

dbaty commented Apr 6, 2021

In the meantime, you may be interested in the pylint-strict-informational plugin which, once installed, transforms informational messages as warnings.

@TylerYep
Copy link

TylerYep commented Apr 10, 2021

Though 1) sounds fine, I really hope 2) is eventually implemented (enabling useless-suppression by default), even though it's a breaking change. Enabling useless-suppression by default helps clean up repositories considerably as Pylint improves, and matches the behavior of tools like mypy or flake8+yesqa.

@papb
Copy link

papb commented Jul 14, 2021

@dbaty That plugin did not work for me unfortunately, should it still work with latest pylint?

@papb
Copy link

papb commented Jul 15, 2021

@TylerYep @dbaty I managed to make another workaround, see Polyconseil/pylint-strict-informational#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors Help wanted 🙏 Outside help would be appreciated, good for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants