当前位置:网站首页>Vscode configuration uses pylint syntax checker

Vscode configuration uses pylint syntax checker

2022-07-07 14:10:00 jiang_ huixin

  1. First installation “Python” plug-in unit

  1. install pylint Grammar checker

It is recommended to install on the current Python Environment

pip3 install pylint

  1. Enable pylint Grammar checker

open VSCode Configuration file for

Add the following :

{
    
    //  Code checking 
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    //  preservation  Python  Check syntax on file 
    "python.linting.lintOnSave": true
}

  1. To configure pylint Grammar checker

establish .pylintrc file

pylint --generate-rcfile > .pylintrc

among pylint be located Python Environmental Science ( Installed in this environment pylint) Medium bin Catalog , Running the above command may require specifying pylint The absolute path of

And then what will be generated .pylintrc Move the file to the root directory of the project

stay VSCode Add configuration to configuration :

{
    
	//  Appoint  .pylintrc  The path of , ${workspaceFolder}  Represents the root directory of the current project 
    "python.linting.pylintArgs": [
        "--rcfile=${workspaceFolder}/.pylintrc"
    ]
}

If pylint Not installed in VSCode Current Python Environmental Science , You need to add the following configurations ( Need to be revised pylint Actual path of )

{
    
    //  Appoint  pylint  The path of 
    "python.linting.pylintPath": "${env:HOME}/Miniconda/bin/pylint"
}
  1. Disable some check items

pylint There is an over check , The following is a prompt for not writing the module document string :

Yes 3 There are three levels of methods to disable such prompts :

  • Add comments to the code
# pylint: disable=missing-module-docstring

  • modify pylint Operation parameters of

modify VSCode Configuration of

The following shows how to disable invalid-name and missing-module-docstring Two inspection items :

{
    
    "python.linting.pylintArgs": [
        "--rcfile=${workspaceFolder}/.pylintrc",
        "--disable=invalid-name,missing-module-docstring"
    ]
}
  • modify .pylintrc file

stay .pylintrc Search for “diable”, Add an item at the end “missing-module-docstring”

disable=raw-checker-failed,
        bad-inline-option,
        locally-disabled,
        file-ignored,
        suppressed-message,
        useless-suppression,
        deprecated-pragma,
        use-symbolic-message-instead,
        not-callable,
        missing-module-docstring
原网站

版权声明
本文为[jiang_ huixin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071211326141.html