8

I use Anaconda's Spyder for some visualization. Got used to code formatter called black when I code in Notepad++. Unfortunately, I don't know to use black with Spyder. Does anyone know?

MiloshB
  • 151
  • 1
  • 2
  • 10
  • Check this question https://stackoverflow.com/questions/40595961/how-to-change-the-spyder-editor-background-to-dark hope it helps – TavoGLC Apr 15 '19 at 22:37
  • 1
    My question has nothing to do with background colour but with formatter black: https://black.readthedocs.io/en/stable/ – MiloshB Apr 15 '19 at 23:08

2 Answers2

14

Since Spyder 4.2, there's support for black built in, though it was set to autopep8 by default for me.

To enable black, go to Tools -> Preferences -> Completion and Linting -> Code Style and Formatting

Under code formatting dropdown, select black

Snippet showing the dropdown for code formatting with black

Then, you can use the default shortcut Ctrl + Alt + i or click the format dropdown under source tab to format a selection or the entire file.

Snippet showing the Source tab dropdown

Paritosh Singh
  • 6,034
  • 2
  • 14
  • 33
9

(Spyder maintainer here) We'll add an option to use the Black formatter in our next version, Spyder 4.2, to be released in November of 2020.

Unfortunately, there's nothing we can do about it for our current version (4.1.5), sorry.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124