Black Beautifier
About
Black beautifier for Unibeautify
Package | Docs | Latest |
---|---|---|
@unibeautify/beautifier-black | v0.1.2 | |
unibeautify | v0.17.1 |
Prerequisites
Please install the following prerequisites.
Black executable
Black executable should not be confused with Black beautifier with the same name. Executables are non-Node.js tools for code formatting while beautifiers are Node.js packages which wrap an executable to be used by Unibeautify.
Black executable is a third-party program you must install manually and is required for beautification.
See https://github.com/ambv/black for more information.
Install Black (black
) by following https://github.com/ambv/black#installation.
If you have questions or want to report a bug, go to https://github.com/ambv/black/issues.
Install
Install with npm
:
npm install --save-dev unibeautify @unibeautify/beautifier-black
Or with yarn
:
yarn add --dev unibeautify @unibeautify/beautifier-black
Usage
Add Black
to beautifiers
language option.
A .unibeautifyrc.json
file would look like the following:
{
"Python": {
"beautifiers": [
"Black"
]
}
}
Advanced
Example advanced configuration:
{
"Python": {
"beautifiers": [
"Black"
],
"Black": {
"Black": {
"path": "/absolute/path/to/black"
}
}
}
}
Options
Option | Python |
---|---|
Wrap Line Length | ✅ |
FAQ
How to use Black in Atom, VSCode, and other editors?
See the editor integration documentation for installation instructions for your editor of choice.
How to enable Black to format on save?
See the editor integration documentation for format on save instructions for your editor of choice.
How to run Black on all files?
You can run Black on all of your files for every commit with Unibeautify CI.
Is there a Black sandbox or playground?
You can quickly try Black online with Unibeautify Playground.
Troubleshooting
Below are instructions for each of the supported Operating Systems.
Windows
Open the Command Prompt.
Show me how to open the Command Prompt.
Find the path to Black by running the command:
where black
Which will return an absolute path like one of the following:
C:\absolute\path\to\black
C:\absolute\path\to\black.exe
C:\absolute\path\to\black.bat
If where
fails to return an executable path then you need to fix your PATH
Environment Variable.
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section and replace /absolute/path/to/black
with your specific executable path value.
macOS
Open the Terminal application.
Show me how to open the Terminal.
Find the path to Black by running the command:
which black
Which will return an absolute path like one of the following:
/absolute/path/to/black
/absolute/path/to/black.sh
/absolute/path/to/black.bash
If which
fails to return an executable path then you need to fix your PATH
Environment Variable:
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section and replace /absolute/path/to/black
with your specific executable path value.
Linux
Open the Terminal application.
Show me how to open the Terminal.
Find the path to Black by running the command:
which black
Which will return an absolute path like one of the following:
/absolute/path/to/black
/absolute/path/to/black.sh
/absolute/path/to/black.bash
If which
fails to return an executable path then you need to fix your PATH
Environment Variable.
Show me how to change my
PATH
environment variable.
If you know the executable path go to the Configure section replace /absolute/path/to/black
with your specific executable path value.