question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Black formatter doesn't format

See original GitHub issue

Environment data

  • VS Code version: 1.32.3
  • OS and version: Mac OS X 10.14.3
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv

Expected behaviour

black to auto-format files.

Actual behaviour

I use black as my main formatter. Neither when saving files nor clicking option+shift+f my files are getting formatted. I can see the message Formatting with black on the status bar, but nothing happens. My black path is set to /Library/Frameworks/Python.framework/Versions/3.6/bin/black, and when I use the command line to run the following command, the file is getting formatted.

/Library/Frameworks/Python.framework/Versions/3.6/bin/black FILE_TO_FORMAT

If I choose a different formatter as default, say autopep8, everything works correctly.

More information

  1. I edited black path to be autopep8’s path, still doesn’t format.
  2. I edited autopep8 path to be black’s path, still nothing.
  3. When setting black path to black and installing black on virtualenv, it works.

Steps to reproduce:

  1. Select black as VSCode formatter
  2. Save a file or type option+shift+f
  3. Now run black FILE_TO_FORMAT in command line for verification

Logs

Nothing mentioning black.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mawkeecommented, Mar 28, 2019

I have the same issue, but only with black 19.3b0; try downgrading it to 18.9b0 and see if that works

0reactions
ericsnowcurrentlycommented, Apr 2, 2019

@AdamGold, that’s great! I’m concerned that we didn’t determine if there’s a bug, but I’m glad it’s working for you now. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formatter black is not working on my VSCode...but why?
Try running black from the command line to see if there are error messages. This is what I got: $ black my_code.py error:...
Read more >
Black formatting is not applied (but black runs) #18561 - GitHub
Issue Type: Bug Behaviour When formatting a *.py file with black, no changes are applied. I can see in the log black being...
Read more >
The Black code style - Black 22.12.0 documentation
Black ignores previous formatting and applies uniform horizontal and vertical whitespace to your code. The rules for horizontal whitespace can be summarized as: ......
Read more >
Setting up python Black on Visual Studio Code | by Marco Belo
Type “format on save” at the search bar on top of the Settings tab and check the box. Search for “python formatting provider”...
Read more >
Black Formatter - Visual Studio Marketplace
Disabling formatting with black. If you want to disable Black formatter, you can disable this extension per workspace in Visual Studio Code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found