我正在使用2018年5月的python扩展(2018年6月发布),用于Windows上的vs代码1.23.1,python 3.6 via anaconda,conda将black从conda forge安装到我的conda环境中。
在my user settings.json中,我有以下内容:
"python.formatting.blackArgs": [
"--line-length 80"
],
我认为这是正确的方法来构造它,以便在vs代码python格式中将参数传递给black。
但是,在我的python输出窗格中,我得到了以下内容:
Formatting with black failed.
Error: Error: no such option: --line-length 80
编辑:如果我将settings.json编辑为无参数,例如:
"python.formatting.blackArgs": [],
黑色按预期工作。
有人知道如何正确地将论点传递给新的(截至2018年6月)黑色格式化程序吗?
最佳答案
examples of formatter-specific settings显示以下内容:
"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"],
"python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"]
所以尝试一下:
"python.formatting.blackArgs": ["--line-length", "80"]
关于python - VS Code Python + Black格式化程序参数 - python.formatting.blackArgs,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50725888/