Visual studio code VS代码的flake8的忽略参数在保存时对格式不起作用?
以下是my settings.json: { python.pythonPath:/home/zhaodachuan/anaconda3/envs/ranking\u engine/bin/python, python.autoComplete.extrapath:[ /mnt/c/Users/hnjyz/OneDrive/jupyter_lab/code/ranking_engine, ], python.linting.pyleIntenabled:false, python.linting.enabled:true, python.linting.flake8Enabled:true, python.linting.flake8Args:[ -最大线路长度=120, -忽略=E402,F401, ], } 但是当我在VS代码中保存时打开格式时,flake8-ignore不起作用Visual studio code VS代码的flake8的忽略参数在保存时对格式不起作用?,visual-studio-code,vscode-settings,flake8,Visual Studio Code,Vscode Settings,Flake8,以下是my settings.json: { python.pythonPath:/home/zhaodachuan/anaconda3/envs/ranking\u engine/bin/python, python.autoComplete.extrapath:[ /mnt/c/Users/hnjyz/OneDrive/jupyter_lab/code/ranking_engine, ], python.linting.pyleIntenabled:false, python.linting
我该怎么办?Flake 8不是格式化程序,它是一个linter 当然是这样,但它不会影响settingeditor.formatOnSave或由formattocument命令触发。如果配置正确,它将自动运行并检查您的文件是否存在可能的问题,然后在“问题”选项卡上显示这些问题: 如果我加上:
"python.linting.flake8Args": [
"--ignore=F401"
],
然后,先前显示的F401错误应消失:
您似乎正在寻找的是格式化程序。请参阅Python上VS代码文档的格式化部分:
格式化通过应用
行距、缩进、间距的特定规则和约定
关于运算符等,请参见页面上的示例。
格式化不会影响代码本身的功能。
另一方面,分析常用语法的代码,
风格、功能错误以及非常规编程
可能导致错误的实践。虽然有一点重叠
在格式化和linting之间,这两种功能是
补充
Python扩展支持使用
默认值,或
安装一个选定的格式化程序,并启用formatOnSave:
什么不工作意味着-flake8不是格式化程序谢谢。我现在在vscode中使用blank。
"[python]": {
"editor.formatOnSave": true
},
"python.formatting.provider": "yapf",
"python.formatting.yapfPath": "/usr/local/bin/yapf",
"python.formatting.yapfArgs": [
"--style=/path/to/setup.cfg"
],