If it's still invoking the built-in Python Language Basics extension, then that means Black isn't configured correctly. There seems to be nothing wrong with the steps you did, so I would suggest just double-checking the settings.
Here, you have to make sure that the Python environment where you installed Black is the same Python environment you activate in VS Code. See the docs on selecting and activating an environment. If you've got multiple Python versions or you are using virtual environments, you'll have to make sure you're activating the correct one.
Python: Select Interpreter

(test-py38) gino@~$ pip install black
Requirement already satisfied: black in ./.venvs/test-py38/lib/python3.8/site-packages (19.10b0)
...
(test-py38) gino@~$ which black
/Users/gino/.venvs/test-py38/bin/black
You can set python.formatting.blackPath
to explicitly specify the path to Black:
"python.formatting.blackPath": "/Users/gino/.venvs/test-py38/bin/black"
You can also try checking if Black is working by calling it manually.
(test-py38) gino@~$ black test.py
reformatted test.py
All done! ✨ ✨
1 file reformatted.
- Set black as the python formatting provider (went to settings, found "Python › Formatting: Provider", selected Black from the drop down)
- Turn on format on save
- Set default formatter to null
Again, double-check your settings.json
"editor.defaultFormatter": null,
"editor.formatOnSave": true,
"python.formatting.provider": "black",
Also, make sure that you're configuring the correct settings, since VS Code has 3 sets of settings User, Workspace, and Folder settings.

When I try to use the format document command
Given that you enabled formatOnSave
, you really don't need to call the Format Document command. When you save the file, it should automatically call the defaultFormatter
(which is null
) so it calls the language-specific formatter (python.formatting.provider
).
If you really want to call that command manually, try Format Document With.. then select Python.
