【发布时间】:2020-08-08 10:41:55
【问题描述】:
我注意到一件奇怪的事情,当我们设置时,VSCode 中的 autopep8 自动格式化不起作用
"python.formatting.autopep8Args": [
"--line-length 119"
],
但如果此设置处于行长 79 的默认模式下,则效果很好。 autopep8 是否存在一些问题,只能在不超过 79 行的情况下工作,或者我在 VSCode 中犯了任何错误。我需要的主要功能是当我的 python 程序行太长时,它应该能够将它分成多行。我不想继续使用 79 个字符的方法。我首选的方法是 119 个字符。目前,我必须手动缩进大行。除了 pep8 之外,是否还有其他格式支持 119 个字符和自动缩进超过 119 个字符的行。
我正在附加我的 settings.json 文件数据
{
"window.zoomLevel": 1,
"python.dataScience.sendSelectionToInteractiveWindow": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.fontSize": 16,
"python.formatting.provider": "autopep8",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"python.autoComplete.addBrackets": true,
"python.formatting.autopep8Args": [
"--line-length 119"
],
// "python.linting.flake8Args": [
// "--max-line-length=120"
// ],
"files.autoSaveDelay": 10000,
"editor.defaultFormatter": "ms-python.python",
"files.autoSave": "afterDelay",
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"editor.quickSuggestions": true,
"editor.codeActionsOnSave": null,
}
【问题讨论】:
-
是不是应该是
--max-line-length=119? -
Pep8 说 --max-line-length=79 但 Django 说 --max-line-length=119。两者都与 Python 相关联。即使在 GitHub 代码审查中也是 119。我只想要支持具有 119 个字符的 python 并自动格式化我的文档而不是我这样做,因为它使用 autopep8 格式化,最大行长 = 79
标签: python visual-studio-code flake8 autopep8