unstale

pypi / black

black

What changed in black 25 to 26, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

11 breaking3 security10 new APIs and options6 performance18 behavior and defaults10 tooling69 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

black 26101 changes

Breaking changes 10

  • The bundled action now rejects URL references and other non-released-version values read from tool.black.required-version, addressing a security issue.

    26.10.1release notessecurity advisory

  • Repeated lines outside the selected ranges are left unchanged.

    26.10.1release notes

  • Preview style parenthesizes expressions with parameter comments when they exceed the line length.

    26.10.1release notes

  • In preview style, short expressions inside brackets are not split on delimiters when preceded by a standalone comment.

    26.10.1release notes

  • Rejects non-string force-exclude values in pyproject.toml.

    26.10.0release notes

  • Rejects non-string include values in pyproject.toml.

    26.10.0release notes

  • T-strings in docstring position are no longer treated as docstrings.

    26.10.0release notes

  • blackd disables browser-originated requests by default.

    26.3.1release notes

  • When enabled in the GitHub Action, parsing of Black requirements accepts only version specifiers and rejects direct references; the update is automatic with psf/black@stable.

    26.3.0release notessecurity advisory

  • Black now matches Git when deciding whether files are ignored: a matching pattern keeps a file ignored even if its parent directory is directly unignored.

    26.1.0release notes

Security 3

  • Black: Arbitrary file writes from unsanitized user input in cache file name

    26.3.1security advisoryrelease notes

  • Short magics use exact-length placeholders, and unmasking aborts if it can no longer be done safely, preventing collisions from corrupting notebook cells.

    26.3.1release notes

  • blackd adds request body limits.

    26.3.1release notes

New APIs and options 6

  • Adds a command-line option to configure the cache directory.

    26.10.1release notes

  • GitHub Action runs expose the is_formatted, change_count, same_count, and failure_count outputs.

    26.10.0release notes

  • The environment variable disables ANSI output.

    26.10.0release notes

  • Adds SourceASTParseError to distinguish source parse failures from internal safety errors and improve reporting when the lenient parser accepts input rejected by ast.parse().

    26.5.0release notes

  • blackd adds configurable origin allowlisting for requests.

    26.3.1release notes

  • Introduces winloop as a Windows alternative to uvloop; blackd can use it when installed to run faster on Windows.

    26.3.0release notes

Performance 6

  • Avoids quadratic runtime when splitting very long lines with many trailing bracket pairs.

    26.10.1release notes

  • Fixes superlinear runtime growth as the number of input files increases.

    26.10.0release notes

  • Improves performance on long calls and collections, soft keywords, semicolon-separated statements, deeply nested expressions, and compound statements with many clauses.

    26.10.0release notes

  • Improves performance on files with many sibling blocks.

    26.10.0release notes

  • Release binaries are smaller because debug symbols are stripped during the PyInstaller release build.

    26.10.0release notes

  • Improves performance on strings with many consecutive backslashes, multiline strings in large collections, and several string-processing operations.

    26.10.0release notes

Behavior and default changes 13

  • Preview style avoids unnecessary parentheses around unbreakable right-hand-side expressions, including in annotated assignments and subscript targets.

    26.10.1release notes

  • Validates line-range values.

    26.10.0release notes

  • Preview style enforces a blank line after a function or method with a docstring-only body when another comment or statement follows.

    26.10.0release notes

  • Unstable style splits long stringified return annotations even when the function has parameters.

    26.10.0release notes

  • The GitHub Action supports PEP 440 version specifiers for tool.black.required-version.

    26.10.0release notes

  • Improves blank-line heuristics before, within, and after groups of same-name decorated functions in .pyi stub files.

    26.5.0release notes

  • Parse errors are more readable, with multi-line output and an error pointer.

    26.5.0release notes

  • blackd bounds executor submissions to improve backpressure.

    26.3.1release notes

  • The 2026 stable style always forces one blank line after import statements, except when the following line is a comment or another import.

    26.1.0release notes

  • Adds \r style newlines to the newline styles that Black can normalize files from and to.

    26.1.0release notes

  • Regenerates the width table and adds Khmer language support.

    26.1.0release notes

  • Expressions involving multiline strings are formatted more compactly.

    26.1.0release notes

  • Removes unnecessary parentheses from assignment left-hand sides while preserving magic trailing commas and intentional multiline formatting.

    25.12.0, 26.1.0release notesrelease notes

Tooling 7

  • Keeps parentheses around a lambda used as the iterable of a comprehension.

    26.10.0release notes

  • Reports parser failures using editor-friendly path:line:column locations.

    26.10.0release notes

  • Preview style normalizes uppercase T prefixes to lowercase.

    26.10.0release notes

  • Preview style parenthesizes tuple expressions for consistency with function calls and returns.

    26.10.0release notes

  • Black adds syntactic support for lazy imports, a Python 3.15 feature.

    26.5.0release notes

  • Black adds syntactic support for unpacking in comprehensions, a Python 3.15 feature.

    26.5.0release notes

  • Formats type comments with zero or more spaces around type: as # type: (value).

    26.1.0release notes

Fixes and other changes 56

  • Black no longer moves an encoding declaration onto the first two lines of a file.

    26.10.1release notes

  • Fixes the action crashing on dependency-group includes when use_pyproject is enabled.

    26.10.1release notes

  • Black respects .gitignore files that start with a UTF-8 byte order mark, so the first pattern matches and ignored files are not formatted.

    26.10.1release notes

  • Long notebook assignment magics such as x = !ls -la are left unchanged instead of being wrapped in parentheses that IPython can no longer run.

    26.10.1release notes

  • Formatting now handles lines following a statement when that statement is joined or re-indented.

    26.10.1release notes

  • Formatting no longer crashes when an unselected statement has a # fmt: skip comment before a closing bracket.

    26.10.1release notes

  • Files formatted or checked with selected line ranges are no longer cached as formatted, preventing later full checks from passing or skipping unformatted lines.

    26.10.1release notes

  • Black no longer adds an extra trailing blank line inside a multi-line module docstring when its last line is near the line length limit.

    26.10.1release notes

  • The unstable feature no longer removes backslash-newline sequences from raw strings and changes their value.

    26.10.1release notes

  • The unstable feature no longer adds a space after * or ** in a PEP 695 type parameter when splitting a string in its default.

    26.10.1release notes

  • Preview style avoids unnecessary line splits of trailers when an earlier bracket split exceeds the line length only because of a trailing comment.

    26.10.1release notes

  • The feature no longer drops parentheses around a right-hand side containing a dictionary and leaves the line over the length limit.

    26.10.1release notes

  • Keeps parentheses around annotated-assignment targets, preserving their effect on __annotations__.

    26.10.0release notes

  • Invalid worker values are reported as usage errors instead of causing a crash.

    26.10.0release notes

  • Fixes crashes on standalone comments between tokens and preserves inline comments on brackets inside comprehensions.

    26.10.0release notes

  • When sources share no common project root, Black falls back to the default configuration with a warning instead of crashing.

    26.10.0release notes

  • Fixes multiline indentation with leading tabs and prevents form feeds or similar characters from becoming newlines.

    26.10.0release notes

  • Preserves blank lines immediately before a # fmt: on comment.

    26.10.0release notes

  • Fixes formatting and crashes involving skipped bracketed expressions, PEP 695 declarations, headers, comments, and one-line statements.

    26.10.0release notes

  • Correctly excludes files whose paths contain .. when invoked from a subdirectory.

    26.10.0release notes

  • Stops converting form feeds and similar characters in docstrings into newlines.

    26.10.0release notes

  • Preview style removes redundant parentheses around generator expressions.

    26.10.0release notes

  • Fixes misplaced or dropped inline comments around optional parentheses, comprehensions, and bracketed expressions.

    26.10.0release notes

  • Fixes parsing assignment magics when non-ASCII characters occur earlier on the line.

    26.10.0release notes

  • No longer inserts an empty line after a docstring when the range covers only the docstring, and preserves comments and blank lines outside requested ranges.

    26.10.0release notes

  • Respects the magic trailing comma in PEP 695 type parameter lists containing a *TypeVarTuple or **ParamSpec.

    26.10.0release notes

  • Fixes crashes when splitting case case if ... patterns at very small line lengths.

    26.10.0release notes

  • Stops dropping trailing commas from split single-element tuple lambda defaults and one-element subscripts.

    26.10.0release notes

  • Preserves CRLF endings on the skipped line instead of turning them into \r\r\n.

    26.10.0release notes

  • Avoids a crash when writing formatted code or diffs to a stdout without a buffer attribute.

    26.10.0release notes

  • Fixes unparseable output when a t-string replacement field contains a quote.

    26.10.0release notes

  • No longer emits a spurious warning when the runtime version is included in the flag.

    26.10.0release notes

  • Fixes unparseable output when the string body ends in an already-escaped double quote.

    26.10.0release notes

  • Preview style removes redundant parentheses around individual variables in unpacking targets.

    26.10.0release notes

  • Blackd returns HTTP 400 for an empty header or empty entry, and accepts optional whitespace around comma-separated versions and pyi.

    26.10.0release notes

  • Fixes unstable formatting when a subscript annotation contains an inline comment.

    26.5.1release notes

  • Corrects the version reported by published executables.

    26.5.1release notes

  • Preserves inline comments immediately before a # fmt: skip line, avoiding AST equivalence failures.

    26.5.1release notes

  • Returns HTTP 400 for source parse failures and reserves HTTP 500 for genuine internal safety errors.

    26.5.0release notes

  • Fixes blank lines being removed between a function and a decorated class in .pyi stub files.

    26.5.0release notes

  • Fixes a crash when an f-string follows a # fmt: off comment inside brackets.

    26.5.0release notes

  • Fixes # fmt: skip being ignored in nested if expressions with parenthesized in clauses.

    26.5.0release notes

  • Preserves multiline compound statement headers when # fmt: skip is placed on the colon line.

    26.5.0release notes

  • Python 3.15 is now supported, though compiled wheels are not yet provided and performance may be slower than on existing Python versions.

    26.5.0release notes

  • Prevents the string merger from creating unsplittable long lines when a pragma comment follows the closing bracket.

    26.5.0release notes

  • Fixes incorrect splitting of if guards when a case pattern has a trailing comma.

    26.3.0release notes

  • Fixes a crash on standalone comments in lambda default arguments.

    26.3.0release notes

  • Black no longer double-decodes input, preventing corruption of non-UTF-8 files.

    26.3.0release notes

  • Disables multiprocessing in frozen environments to fix shutdown errors in PyInstaller builds on macOS.

    26.3.0release notes

  • Fixes a crash on unassigned long string literals with trailing commas, such as one-item tuples.

    26.3.0release notes

  • When the target Python version is newer than the running Python, Black emits a clear warning and an actionable error explaining that AST safety checks cannot parse newer syntax.

    26.3.0release notes

  • Preserves parentheses when type-ignore comments would otherwise be merged, preventing AST equivalence failures.

    26.3.0release notes

  • Fixes # fmt: skip on one-liner declarations so the declaration is not incorrectly collapsed.

    26.1.0release notes

  • Comments before a module docstring no longer cause it to be treated as a normal string.

    25.11.0, 26.1.0release notesrelease notes

  • Removes parentheses around multiple exception types in except and except* clauses without as.

    26.1.0release notes

  • Fixes how type expansions are split in generic functions.

    26.1.0release notes

black 2526 changes

Breaking changes 1

  • Black no longer supports running with Python 3.9.

    25.12.0release notes

New APIs and options 4

  • The GitHub Action accepts an output-file input to write formatter output to a file for artifact capture and cleaner logs.

    25.12.0release notes

  • Releases now include binaries for arm64 Linux.

    25.11.0release notes

  • Adds a simple Python client for sending formatting requests to blackd.

    25.11.0release notes

  • Adds an option to control caching behavior.

    25.11.0release notes

Behavior and default changes 5

  • Comments containing fmt directives preserve their exact formatting instead of being normalized.

    25.11.0release notes

  • This feature moves from --unstable to --preview.

    25.11.0release notes

  • The GitHub Action supports the major-version-only “stability” format for required-version when using pyproject.toml.

    25.11.0release notes

  • The Vim plugin warns about unsupported Vim and Python versions independently.

    25.11.0release notes

  • When importing black fails, the Vim plugin prints the import paths.

    25.11.0release notes

Tooling 3

  • Black supports Python 3.14 as a target version.

    25.11.0release notes

  • Black can format the new Python 3.14 t-string syntax introduced by PEP 750.

    25.11.0release notes

  • Type comments are standardized to the form # type: <value>.

    25.11.0release notes

Fixes and other changes 13

  • Fix a preview-style crash in fix_fmt_skip_in_one_liners on annotated parameters.

    25.12.0release notes

  • Releases now include arm64 Windows binaries and wheels.

    25.12.0release notes

  • Fix a possible crash when fmt: directives are not at the top level.

    25.12.0release notes

  • Comments preceding these blocks are no longer incorrectly removed, including Jupytext markdown cell comments.

    25.12.0release notes

  • Fix crashes when multiple skip comments are used in multi-part if-clauses, on string literals, or on dictionary entries with long lines.

    25.12.0release notes

  • In preview style, the directive now skips the line it is on rather than the following line.

    25.12.0release notes

  • Preview style no longer adds new lines after imports marked with this directive.

    25.12.0release notes

  • Fix a preview-style crash in fix_fmt_skip_in_one_liners on with statements.

    25.12.0release notes

  • Comments between # fmt: off and # fmt: on are no longer reformatted.

    25.11.0release notes

  • The preview feature now respects # fmt: skip for compound statements with semicolon-separated bodies.

    25.11.0release notes

  • Fixes an issue with how line breaks are inserted in Python 3.12 generics syntax.

    25.11.0release notes

  • When formatting is excluded from stdin piped through a command, unchanged content is written to stdout.

    25.11.0release notes

  • The Vim plugin now handles virtualenvs that use a different Python version.

    25.11.0release notes