VS Code Python + Black formatter arguments - python.formatting.blackArgs

后端 未结 4 1811
挽巷
挽巷 2021-01-04 06:59

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 e

相关标签:
4条回答
  • 2021-01-04 07:24

    The proper way to config in the Settings GUI pane is with --line-length and the desired value as separate items:

    Visual Studio Code GUI Settings for Python Formatting

    This converts into the settings.json into this:

    Visual Studio Code JSON Settings for Python Formatting

    "python.formatting.provider": "black",
    "python.formatting.blackArgs": ["--line-length", "110"]
    
    0 讨论(0)
  • 2021-01-04 07:30

    Well, I was fighting with new VSCode settings myself. I tried all things suggested in the other answers with many variations, and result was nil.

    Then, I've reached enlightenment. Here you are for version 1.38.1 and further. Note there are no quotation marks.

    --line-length=80  
    

    0 讨论(0)
  • My setting is: "python.formatting.blackArgs": ["--line-length=110"] and it's working correctly. The equal sign was missing in your user settings.json

    0 讨论(0)
  • 2021-01-04 07:41

    The examples of formatter-specific settings show the following:

    "python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"],
    "python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"]
    

    So try:

    "python.formatting.blackArgs": ["--line-length", "80"]
    
    0 讨论(0)
提交回复
热议问题