pylint
pylint copied to clipboard
[unknown-option-value] False negative after `--disable=all`
Bug description
The option --enable does not give an error when an unknown error code is used. It should give an error.
What I was trying is to enable just a group of warnings. I tried W1 and W1*. No error but also no warning. But the code does have some W1203 problems in it.
Configuration
No response
Command used
pylint --disable=all --enable=foobar bandas.py
Pylint output
-------------------------------------------------------------------- Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
Expected behavior
Give an error.
Pylint version
pylint 2.17.7
astroid 2.15.8
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
OS / Environment
Debian 12 arm64
Additional dependencies
No response
Reproduced @ 51c28bc922dfb8da42e680ed7190eb942889df01
pylint --enable=missnig-docstring pylint/checkers/utils.py
************* Module Command line
Command line:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'missnig-docstring' (unknown-option-value)
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
pylint --disable=all --enable=missnig-docstring pylint/checkers/utils.py
No files to lint: exiting.
As I also ran into this issue I started debugging it to check for a fix.
The reason seems to be that --disable=all also disables the unknown-option-value messages.
Thus when running
pylint --disable=all --enable=unknown-option-value,missnig-docstring pylint/checkers/utils.py
************* Module Command line
Command line:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'missnig-docstring' (unknown-option-value)
------------------------------------
Your code has been rated at 10.00/10
the results is again as expected.
While I understand this behavior for --disable=all, I think it is not very intuitive from a user perspective. I did not expect to silent pylint error messages, most people would assume it only silents linting errors.
Would it make sense to have internal pylint errors not being affected by --disable=all?
Yep, exactly! This issue is ready for a contributor to tackle.