VS Code Python + 黑色格式化程序参数 - python.formatting.blackArgs [英] VS Code Python + Black formatter arguments - python.formatting.blackArgs

查看:35
本文介绍了VS Code Python + 黑色格式化程序参数 - python.formatting.blackArgs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using the May 2018 Python extension (released June 2018) for VS Code 1.23.1 on Windows, python 3.6 via Anaconda, conda installing black from conda-forge into my conda environment.

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

In my user settings.json I have the below:

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

认为将是构建它以将参数传递给 VS Code Python 格式中的 black 的正确方法.

which I'd think would be the correct way to structure this to pass arguments to black in VS Code Python formatting.

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

However, in my python Output pane I get the below:

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

如果我将 settings.json 编辑为没有参数,例如:

If I edit my settings.json to be no args, such as:

"python.formatting.blackArgs": [],

黑色按预期工作.

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

Does anyone know how to pass arguments correctly to the new (as of June 2018) black formatter?

推荐答案

问题是在 --line- 之后需要 =80 而不是 801.38.1 及以上版本的长度:

The issue is that you need =80 instead of 80 after --line-length for version 1.38.1 and above:

--line-length=80  

这篇关于VS Code Python + 黑色格式化程序参数 - python.formatting.blackArgs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆