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:

enter image description here enter image description here

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:

enter image description here

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

enter image description here

You can do the same for all the other PyLint categories.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐