LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

black

Opinionated Python code formatter

TLDR

Format Python file
$ black [script.py]
copy
Format entire project
$ black [src/]
copy
Check without modifying
$ black --check [script.py]
copy
Diff instead of rewriting
$ black --diff [script.py]
copy
Set line length
$ black -l [100] [script.py]
copy

SYNOPSIS

black [options] files

DESCRIPTION

black is an opinionated Python code formatter. It enforces a consistent style by reformatting code automatically with minimal configuration. Black's approach is to eliminate debate about formatting by providing one correct way.The tool integrates with editors and CI pipelines to ensure consistent Python code style.

PARAMETERS

--check

Check if files would be reformatted (exit 1 if yes)
--diff
Show diff instead of rewriting
-l, --line-length n
Line length (default: 88)
--target-version py
Python version (py37, py38, py39, etc.)
--exclude pattern
Files/directories to exclude
--include pattern
Files/directories to include
--quiet
Minimal output
--verbose
Verbose output
--color/--no-color
Colored output

CONFIGURATION

pyproject.toml

Project-level configuration under `[tool.black]` section. Supports `line-length`, `target-version`, `include`, and `exclude` settings.

INSTALL

sudo apt install black
copy
sudo dnf install black
copy
sudo apk add black
copy
brew install black
copy
nix profile install nixpkgs#black
copy

CAVEATS

Opinionated (limited configuration). May conflict with other formatters. 88 character default line length differs from PEP 8's 79. Some formatting choices controversial. Requires Python 3.6+.

HISTORY

Black was created by Łukasz Langa in 2018 to provide deterministic Python formatting, eliminating formatting debates and reducing diff noise.

SEE ALSO

autopep8(1), isort(1), flake8(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid