繁体   English   中英

Visual Studio Code pylint 不适用于 Ubuntu

[英]Visual Studio Code pylint not working on Ubuntu

我想使用 pylint 在 Ubuntu 18.04 上为 python 在 VS-Code 中启用 linting。 我的工作区设置如下所示:

{
  "python.pythonPath": "venv/bin/python",
  "python.linting.pylintEnabled": true,
  "python.linting.enabled": true
}

我的用户设置是这样的:

{
  "window.zoomLevel": 0,
  "explorer.confirmDelete": false,
  "explorer.confirmDragAndDrop": false,
  //"python.jediEnabled": false,
  "kite.showWelcomeNotificationOnStartup": false,
  "[python]": {},
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[html]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "editor.tabSize": 4,
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "C_Cpp.updateChannel": "Insiders",
  "workbench.startupEditor": "newUntitledFile",
  "workbench.iconTheme": "material-icon-theme",
  "workbench.colorTheme": "Predawn",
  "workbench.settings.editor": "json",
  "workbench.settings.openDefaultSettings": true,
  "workbench.settings.useSplitJSON": true,
  "python.pythonPath": "/usr/bin/python3.8",
  "python.formatting.provider": "black",
  "editor.formatOnSave": true
}

但是当我 select Python: Run Linting时,我没有得到任何 linting 错误。 在我的示例中,我希望 linter 抱怨未使用的导入或变量。

我的 VS 代码设置

在 stackoverflow 上的这个问题的答案中找到了帮助,尽管它与 Windows 和 Mac 有关。

就我而言,我在工作空间的根目录中有一个 hand-crafted.pylintrc 文件,并在 Windows(UTF8 编码)上创建,其中包含

扩展-pkg-白名单=cv2

通过运行替换文件

pylint --generate-rcfile > /.pylintrc

在 Ubuntu 上并重新分配我的白名单为我解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM