python - VS Code Python + Black 格式化程序参数 - python.formatting.blackArgs

标签 python visual-studio-code python-black

我在 Windows 上使用 VS Code 1.23.1 的 2018 年 5 月 Python 扩展(2018 年 6 月发布),通过 Anaconda 的 python 3.6,conda 从 conda-forge 安装 black 到我的 conda 环境中。

在我的用户 settings.json 中,我有以下内容:

"python.formatting.blackArgs": [
    "--line-length 80"
],

认为将是构建此结构以将参数传递给 VS Code Python 格式的 black 的正确方法。

但是,在我的 python 输出 Pane 中,我得到以下内容:

Formatting with black failed.
Error: Error: no such option: --line-length 80

编辑:如果我将我的 settings.json 编辑为无参数,例如:

"python.formatting.blackArgs": [],

黑色按预期工作。

有谁知道如何将参数正确传递给新的(截至 2018 年 6 月)黑色格式化程序?

最佳答案

问题是对于 1.38.1 及更高版本,在 --line-length 之后需要 =80 而不是 80:

--line-length=80  

enter image description here

关于python - VS Code Python + Black 格式化程序参数 - python.formatting.blackArgs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50725888/

相关文章:

python - GitLab CI Python 黑色格式化程序说 : would reformat, 而运行黑色不会重新格式化

python - PyCharm:在区域上运行 `black -S`

Python3 在同一行打印 - 7 段设备格式的数字

python - 包括 Django FileUpload 的 Content-disposition header

java - 如何在Java Gradle项目中包括对库的引用

ubuntu - 在 Ubuntu 12.04 上的 Visual Studio Code 中仅打开特定文件夹

google-colaboratory - 用于 google colab 的代码格式化程序,如 nb_black

python - 在不使用循环的情况下选择列表的前 n 项。

python - 在 Ipython Notebook 中禁用 INFO 日志记录消息

macos - 在Visual Studio Code中仅缩放文本