About this project
Black is an opinionated Python code formatter maintained by the Python Software Foundation. Its stated goal is to end debates about hand-formatting by applying a single, consistent style: users cede control over formatting minutiae in exchange for speed, determinism, and freedom from style-checker complaints.
Key characteristics described in the README:
- Reformats entire files in place, ignoring previous formatting (with documented pragmatic exceptions).
- Deliberately limited configuration options; sensible defaults are emphasized, with project settings readable from pyproject.toml (for example include/exclude patterns).
- Aims to produce the smallest possible diffs, which the project says makes code review faster.
- Includes a safety check that the reformatted code still produces a valid AST effectively equivalent to the original; a --fast flag skips this check.
- Claims PEP 8 compliance and a stability policy governing style changes.
Installation and usage:
- Install via pip install black; requires Python 3.10 or newer.
- Jupyter Notebook formatting is available through the black[jupyter] extra.
- Standalone PyInstaller-built executables are offered in GitHub releases for users without a Python installation.
- Run as black {source_file_or_directory} or python -m black {source_file_or_directory}.
Ecosystem and adoption:
The README lists many open-source projects that use Black, including pytest, tox, Pyramid, Django, Django Channels, Hypothesis, attrs, SQLAlchemy, Poetry, PyPA applications, pandas, Pillow, Twisted, LocalStack, Home Assistant, Zulip, and Kedro. It also names organizations such as Dropbox, Lyft, Mozilla, Quora, Duolingo, and Tesla as users. Testimonials are quoted from developers including Mike Bayer, Hynek Schlawack, Kenneth Reitz, and Carl Meyer.
The project is MIT licensed, provides documentation on ReadTheDocs, maintains a changelog and author list in separate files, and invites contributions via its contributing documentation and Discord chat. It also references the Python Community Code of Conduct.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.