Black is a code formatter written in Python, and reformats Python 2.x
and 3.x code.
Black reformats entire files in place. It is not configurable. It
does not take previous formatting into account. The coding style
enforced is a PEP-8 subset, adheres to PEP-257, and otherwise passes
the rules of the "pycodestyle" checker. Black skips over blocks that
start and end with "# fmt: off" and "# fmt: on", respectively. It
also recognizes YAPF's block comments to the same effect.
Provides
Requires
License
MIT
Changelog
* Sun Nov 01 2026 Dirk Müller <dmueller@suse.com>
- update to 26.10.1:
* Fix a long Jupyter notebook assignment magic (for example `x
= !ls -la`) being wrapped in parentheses, which IPython can no
longer run; such cells are now left unchanged
* Keep repeated lines outside the selected `--line-ranges`
unchanged
* Fix `--line-ranges` formatting lines that follow a statement
when formatting joins or re-indents that statement
* Fix `--line-ranges` crashing with an internal error when an
unselected statement has a `# fmt: skip` comment on the last
line before a closing bracket
* Prevent moving an encoding declaration (for example `# -*-
coding: latin-1 -*-`) onto the first two lines of a file
* Fix adding an extra trailing blank line inside a multi-line
module docstring when its last line is near the line length limit
* Wed Jun 17 2026 Daniel Garcia <daniel.garcia@suse.com>
- Update to 26.5.1:
Stable style:
* Fix unstable formatting of annotated assignments whose subscript
annotation contains an inline comment
(e.g. x: list[ # pyright: ignore[...]) (#5130)
* Preserve inline comments (including # type: ignore) immediately
before a # fmt: skip line, avoiding AST equivalence failures
(#5139)
Packaging:
* Correct the version in the published executables (#5137)
Version 26.5.0
Highlights:
* Add support for unpacking in comprehensions (PEP 798) and for lazy
imports (PEP 810), both new syntactic features in Python 3.15
(#5048)
* Python 3.15 is now supported. Compiled wheels are not yet provided
for Python 3.15, so performance may be slower than on existing
Python versions. Wheels will be provided once Python 3.15 is later
in its release cycle. (#5127)
Stable style:
* Fix # fmt: skip being ignored in nested if expressions with
parenthesized in clauses (#4903)
* Add syntactic support for Python 3.15 (#5048)
* Fix crash when an f-string follows a # fmt: off comment inside
brackets (#5097)
* Preserve multiline compound statement headers when # fmt: skip is
placed on the colon line (#5117)
Preview style:
* Improve heuristics around whether blank lines should appear
before, within and after groups of same-name decorated functions
(such as @overload groups) in .pyi stub files (#5021)
* Fix blank lines being removed between a function and a decorated
class in .pyi stub files (#5092)
* Prevent string merger from creating unsplittable long lines when a
pragma comment (e.g. # type: ignore) follows the closing bracket
(#5096)
Output:
* Improve parse error readability by showing multi-line output with
an error pointer. (#5068)
* Add SourceASTParseError to distinguish source parse failures from
internal safety errors, improving error reporting when Black's
lenient parser accepts input that ast.parse() rejects (#5080)
Blackd:
* Return HTTP 400 (Bad Request) for source parse failures instead of
HTTP 500, keeping HTTP 500 only for genuine internal safety errors (#5080)
Integrations:
* Added documentation for doctest formatting tools and updated the
integrations index to match (#4916)
Documentation:
* Use "Version X.Y.Z" headings in changelog for stable permalink
anchors on ReadTheDocs (#5063)
* Note in the editor integrations that the Su