unstale

pypi / black

black

What changed in black 26, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.

7 breaking2 security6 new APIs and options6 performance5 behavior and defaults4 tooling38 fixes and other

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

npx @unstale/cli init

@unstale/cli on npm

black 2668 changes

Breaking changes 7

  • 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 notes

  • 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

Security 2

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

    26.3.1security advisory

  • Black is the uncompromising Python code formatter. Black provides a GitHub action for formatting code. This action supports an option, use_pyproject: true, for reading the version of Black to use from the repository pyproject.toml. A malicious pull request could edit

    26.3.0security advisory

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

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

    26.10.0release notes

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

    26.10.0release 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

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 5

  • 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

Tooling 4

  • 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

Fixes and other changes 38

  • 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