当前位置:网站首页>VSCode 配置使用 PyLint 语法检查器
VSCode 配置使用 PyLint 语法检查器
2022-07-07 12:11:00 【jiang_huixin】
- 首先安装 “Python” 插件
- 安装
pylint
语法检查器
推荐安装在当前的 Python 环境中
pip3 install pylint
- 启用
pylint
语法检查器
打开 VSCode 的配置文件
添加以下内容:
{
// 代码检查
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
// 保存 Python 文件时检查语法
"python.linting.lintOnSave": true
}
- 配置
pylint
语法检查器
创建 .pylintrc 文件
pylint --generate-rcfile > .pylintrc
其中 pylint 位于 Python 环境(在该环境中安装的 pylint)中的 bin 目录, 运行以上命令可能要指定 pylint 的绝对路径
然后将生成的 .pylintrc 文件移至项目的根目录下
在 VSCode 配置中添加配置:
{
// 指定 .pylintrc 的路径, ${workspaceFolder} 表示当前项目的根目录
"python.linting.pylintArgs": [
"--rcfile=${workspaceFolder}/.pylintrc"
]
}
如果 pylint 没有安装在 VSCode 当前的 Python 环境, 则需要添加以下配置(需修改 pylint 的实际路径)
{
// 指定 pylint 的路径
"python.linting.pylintPath": "${env:HOME}/Miniconda/bin/pylint"
}
- 禁用某些检查项
pylint 存在过度检查的情况, 以下是没有写模块文档字符串的提示:
有 3 种级别的方法禁用这样的提示:
- 代码处添加注释
# pylint: disable=missing-module-docstring
- 修改 pylint 的运行参数
修改 VSCode 的配置
以下展示了如何禁用 invalid-name 和 missing-module-docstring 两种检查项:
{
"python.linting.pylintArgs": [
"--rcfile=${workspaceFolder}/.pylintrc",
"--disable=invalid-name,missing-module-docstring"
]
}
- 修改 .pylintrc 文件
在 .pylintrc 文件中搜索 “diable”, 在末尾添加一项 “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
边栏推荐
- Clickhouse (03) how to install and deploy Clickhouse
- Is the spare money in your hand better to fry stocks or buy financial products?
- [AI practice] Application xgboost Xgbregressor builds air quality prediction model (II)
- call undefined function openssl_cipher_iv_length
- Redis 核心数据结构 & Redis 6 新特性详
- call undefined function openssl_ cipher_ iv_ length
- Laravel5 call to undefined function OpenSSL cipher IV length() error php7 failed to open OpenSSL extension
- Build a secure and trusted computing platform based on Kunpeng's native security
- 2022-7-6 Leetcode 977. Square of ordered array
- 得物客服热线的演进之路
猜你喜欢
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
AI人才培育新思路,这场直播有你关心的
AI talent cultivation new ideas, this live broadcast has what you care about
Take you to master the three-tier architecture (recommended Collection)
118. Yanghui triangle
XML文件的解析操作
《厌女:日本的女性嫌恶》摘录
2022-7-6 Leetcode 977. Square of ordered array
Build a secure and trusted computing platform based on Kunpeng's native security
Hands on Teaching: XML modeling
随机推荐
内存溢出和内存泄漏的区别
2022-7-6 Leetcode 977.有序数组的平方
Drawerlayout suppress sideslip display
FCOS3D label assignment
Flask session forged hctf admin
648. Word replacement: the classic application of dictionary tree
最长上升子序列模型 AcWing 1014. 登山
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
参数关键字Final,Flags,Internal,映射关键字Internal
3D Detection: 3D Box和点云 快速可视化
call undefined function openssl_ cipher_ iv_ length
Learning breakout 2 - about effective learning methods
.net core 关于redis的pipeline以及事务
AI talent cultivation new ideas, this live broadcast has what you care about
Dry goods | summarize the linkage use of those vulnerability tools
648. 单词替换 : 字典树的经典运用
高等数学---第八章多元函数微分学1
Build a secure and trusted computing platform based on Kunpeng's native security
Huawei image address
Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)