微软近日发布公告,表示已将 Visual Studio Code 的 Python 扩展中的 linting 功能独立拆分了出来,并形成了一个独立的 扩展,此次拆分的目的是为了提高性能和稳定性,并且不再要求在 Python 环境中安装这个工具,此外拆分后的功能还可以以扩展的形式单独进行更新。

这个新的扩展使用了 Language Server Protocol(语言服务器协议)来提供对 linting 处理的支持,并附带最新版本的 pylint(目前是 2.13.4 版本)。
虽然微软发布的这个扩展的名称是 Pylint,并且也附带了最新版本的 pylint,但它与 Python 开发中大家熟知的 pylint 还是有很大差异(微软在命名上就十分具有迷惑性)。
其中后者 pylint 是一个开源的静态代码分析工具,并具有高度可配置的特点,用户可以根据自己的需求以某种方式扩展 pylint。作为一个非常实用的工具,Emacs、Vim、Atom 等编辑器中都集成了 pylint,而前者仅支持 Visual Studio Code。
它还提供了额外的方法来配置通过 pylint 报告的问题的严重性等级,例如:
“pylint.severity” : {
"convention": "Information",
"error": "Error",
"fatal": "Error",
"refactor": "Hint",
"warning": "Warning",
"info": "Information",
"W0611": "Error", //per error code
"unused-import": "Error" //per error diagnostic
但目前需要注意的是:如果开发者在 Python 扩展中也启用了 pylint,可能会在问题面板中看到同一个问题的两个条目。你可以通过设置 "python.linting.pylintEnabled":false 来禁用内置的 linting 功能。

开发者今天就可以从 VS Code 的市场中安装这个新的扩展来试试。如果你有任何问题或功能请求,可以在 Pylint 扩展的 GitHub 仓库中提出。