J. *_*ers 5 python pylint autopep8 visual-studio-code linter
我最近切换到了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
}
}
Run Code Online (Sandbox Code Playgroud)
这些设置至少现在可以确保保存时的格式将行数保持在最大100,并且不会将我的所有文件行都换成79。如果没有警告,那还是很棒的。
如何禁用这些短毛猫警告?
Cod*_*ker 21
自 2021 年起(Pylint 参考),将其添加到您的.vscode/settings.json
文件中:
"python.linting.pylintArgs": ["--max-line-length=100"]
Run Code Online (Sandbox Code Playgroud)
Jan*_*nos 10
对于pycodestyle
在Vscode 1.15.1:
"python.linting.pycodestyleArgs": ["--max-line-length=100"],
Run Code Online (Sandbox Code Playgroud)
我想出了怎么做。将此行添加到您的设置:
"python.linting.pep8Args": ["--max-line-length=100"],
Run Code Online (Sandbox Code Playgroud)
小智 6
对我来说以下工作有效。(VSCode 版本==1.73.0)
前往设置。
搜索“pylint”。
向下滚动到“Pylint:Args”
点击“添加项目”
输入,--max-line-length=200
将最大线长度调整为您想要的长度。
2020年版本:
将以下条目添加到您的settings.json文件中
"python.linting.pylintArgs": ["-d", "C0301"],
Run Code Online (Sandbox Code Playgroud)
如果您尚未禁用这些错误,并且在 VSCode 中的“问题”下遇到行太长警告,或者将鼠标悬停在带下划线的错误上,您将看到 VSCode 会显示以下内容:
Line too long (188/100)Pylint(C0301:line-too-long)
Run Code Online (Sandbox Code Playgroud)
如您所见,该值C0301
直接来自此警告消息。您还可以通过错误代码禁用其他警告。
归档时间: |
|
查看次数: |
3121 次 |
最近记录: |