簡體   English   中英

帶有 PyLint 和 autoPep8 的 Visual Studio 代碼:如何避免 PyLint 抱怨我的行長?

[英]Visual Studio code with PyLint and autoPep8: How can I avoid PyLint to complain about my line length?

我最近切換到 Visual Studio Code,我不得不說到目前為止我很喜歡它。

我正在開發一個 Python 項目,其中包括 pip 包pylintautopep8 ,我配置了 VSCode 以根據這些包格式化代碼。

唯一的問題是:在 Python 項目中,我正在處理的行長度為 100。所以我的所有代碼如下所示:

錯誤說:`E501:line too long (97 > 79 characters)

錯誤說: E501:line too long (97 > 79 characters) 這是我的 VSCode 設置:

{
  "python.pythonPath": "~/.envs/myProject/bin/python",
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "~/.envs/myProject/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django", "--max-line-length=100"],
  "python.formatting.autopep8Args": ["--max-line-length=100"],
  "python.linting.pylintEnabled": true,
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true
  }
}

這些設置至少現在確保保存時的格式將行保持在最大 100 行,並且不會將我的所有文件行都包裝到 79 行。如果沒有警告,它仍然會很棒。

如何禁用這些 linter 警告?

我最近改用了Visual Studio Code,到目前為止,我不得不說我很喜歡它。

我正在研究一個Python項目,其中包括pip包pylintautopep8並且我配置了VSCode以根據這些包格式化代碼。

唯一的問題是:在Python項目中,我正在處理的行長是100。所以我的所有代碼如下所示:

錯誤消息:`E501:行太長(97> 79個字符)

錯誤消息: E501:line too long (97 > 79 characters) 這是我的VSCode設置:

{
  "python.pythonPath": "~/.envs/myProject/bin/python",
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "~/.envs/myProject/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django", "--max-line-length=100"],
  "python.formatting.autopep8Args": ["--max-line-length=100"],
  "python.linting.pylintEnabled": true,
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true
  }
}

這些設置至少現在可以確保保存時的格式將行數保持在100個最大值,並且不會將我的所有文件行都換成79行。如果沒有警告,那還是很棒的。

如何禁用這些短毛貓警告?

我最近改用了Visual Studio Code,到目前為止,我不得不說我很喜歡它。

我正在研究一個Python項目,其中包括pip包pylintautopep8並且我配置了VSCode以根據這些包格式化代碼。

唯一的問題是:在Python項目中,我正在處理的行長是100。所以我的所有代碼如下所示:

錯誤消息:`E501:行太長(97> 79個字符)

錯誤消息: E501:line too long (97 > 79 characters) 這是我的VSCode設置:

{
  "python.pythonPath": "~/.envs/myProject/bin/python",
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "~/.envs/myProject/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django", "--max-line-length=100"],
  "python.formatting.autopep8Args": ["--max-line-length=100"],
  "python.linting.pylintEnabled": true,
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true
  }
}

這些設置至少現在可以確保保存時的格式將行數保持在100個最大值,並且不會將我的所有文件行都換成79行。如果沒有警告,那還是很棒的。

如何禁用這些短毛貓警告?

我最近改用了Visual Studio Code,到目前為止,我不得不說我很喜歡它。

我正在研究一個Python項目,其中包括pip包pylintautopep8並且我配置了VSCode以根據這些包格式化代碼。

唯一的問題是:在Python項目中,我正在處理的行長是100。所以我的所有代碼如下所示:

錯誤消息:`E501:行太長(97> 79個字符)

錯誤消息: E501:line too long (97 > 79 characters) 這是我的VSCode設置:

{
  "python.pythonPath": "~/.envs/myProject/bin/python",
  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "~/.envs/myProject/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django", "--max-line-length=100"],
  "python.formatting.autopep8Args": ["--max-line-length=100"],
  "python.linting.pylintEnabled": true,
  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true
  }
}

這些設置至少現在可以確保保存時的格式將行數保持在100個最大值,並且不會將我的所有文件行都換成79行。如果沒有警告,那還是很棒的。

如何禁用這些短毛貓警告?

對我來說,以下工作有效。 (VSCode 版本 == 1.41.1)

前往設置。

搜索“pylint”。

向下滾動到“Python > Linting:Pycodestyle Args”

點擊“添加項目”

輸入,“python.linting.pep8Args”:[“--max-line-length=200”]

將 max-line-length 調整為您想要的長度。

截至 2021 年( Pylint 參考),將其添加到您的.vscode/settings.json文件中:

"python.linting.pylintArgs": ["--max-line-length=100"]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM