prospector-dev / prospector

Inspects Python source files and provides information about type and location of classes, methods etc
GNU General Public License v2.0
1.95k stars 173 forks source link

[BUG] Wrong locally-disabled error when using with .pylintrc #460

Open NoamNol opened 2 years ago

NoamNol commented 2 years ago

I have .pylintrc file in my project, and when I run prospector I get pylint - locally-disabled warnings about every # pylint: disable=some-rule comment in the code.

To fix it I need to add disable=locally-disabled to .pylintrc.

To Reproduce In mac:

python -m venv .env
source .env/bin/activate
pip install prospector

cat >> file.py <<EOL
# pylint: disable=consider-using-with
open('f.txt', encoding='utf8').close()
EOL

cat >> .pylintrc <<EOL
[MESSAGES CONTROL]
disable=missing-docstring
EOL

prospector

To fix:

rm .pylintrc
cat >> .pylintrc <<EOL
[MESSAGES CONTROL]
disable=missing-docstring,locally-disabled
EOL

prospector

Expected behavior No warning when using # pylint: disable=some-rule.

Environment:

Additional context

❯ pip freeze
astroid==2.8.4
dodgy==0.2.1
flake8==3.9.2
flake8-polyfill==1.0.2
isort==5.10.0
lazy-object-proxy==1.6.0
mccabe==0.6.1
pep8-naming==0.10.0
platformdirs==2.4.0
prospector==1.5.1
pycodestyle==2.7.0
pydocstyle==6.1.1
pyflakes==2.3.1
pylint==2.11.1
pylint-celery==0.3
pylint-django==2.4.4
pylint-flask==0.6
pylint-plugin-utils==0.6
PyYAML==6.0
requirements-detector==0.7
setoptconf-tmp==0.3.1
snowballstemmer==2.1.0
toml==0.10.2
typing-extensions==3.10.0.2
wrapt==1.13.3
Pierre-Sassoulas commented 2 years ago

Not wanting to activate this except in very particular occasion makes sense, I would merge a fix for that.

carlio commented 2 years ago

Ah so this is a bit tricky - it's "forced" on for prospector to gather information, see https://github.com/PyCQA/prospector/blob/master/prospector/tools/pylint/__init__.py#L70

It should however not be emitted later if disabled elsewhere, only used internally.

I will look into this.