Answer a question

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.

In my user settings.json I have the below:

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

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

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

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

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

"python.formatting.blackArgs": [],

black works as expected.

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

Answers

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

--line-length=80  

enter image description here

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐