How to enable "too-many-locals" Pylint message in VS Code?
Answer a question
I cleaned up my code so that it passed linting in Visual Studio Code with the following settings:
"python.linting.pylintEnabled": true,
"python.linting.pylintUseMinimalCheckers": false,
Then I ran pylint directly and imagine my surprise when several new messages of a type "too-many-" popped up that I then accounted for in my source file with:
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches
I headed over to the Linting Python in Visual Studio Code documentation and read that some specific things are still enabled/disabled. My question then is: how do I get Visual Studio Code to use Pylint the same as if it's running with no arguments and therefore enable messages like these?
Answers
The too-many-locals PyLint message is under the category "Refactor (R)", which by default, is set to be displayed as a "Hint (light bulbs)" only. It is still enabled but hints are not shown in the Problems panel (or on any Error/Warning indicator that I know of), only in the code as a tooltip:

If you want to also show them in the Problems panel, in addition to this:
"python.linting.pylintEnabled": true,
"python.linting.pylintUseMinimalCheckers": false,
you can also configure the python.linting.pylintCategorySeverity.xxx settings. For example, for "too-many-locals", change refactor from "Hint" to "Warning":
"python.linting.pylintCategorySeverity.refactor": "Warning",
Alternatively, from the Settings UI:

Once you've changed it to Error or Warning, it will now appear in the Problems panel along with all other Refactor types:

You can do the same for all the other PyLint categories.
更多推荐
所有评论(0)