簡體   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