我最近切换到 Visual Studio Code,我不得不说到目前为止我很喜欢它。
我正在开发一个 Python 项目,其中包括 pip 包 pylint
和 autopep8
我配置 VSCode 以根据这些包格式化代码。
唯一的问题是:在我处理的 Python 项目中,行的长度是 100。所以我所有的代码都是这样的:
错误显示: 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 警告?
原文由 J. Hesters 发布,翻译遵循 CC BY-SA 4.0 许可协议
我想出了如何做到这一点。将此行添加到您的设置中: