| 1 |
# Change Log |
| 2 |
|
| 3 |
## Version 26.5.1 |
| 4 |
|
| 5 |
### Stable style |
| 6 |
|
| 7 |
- Fix unstable formatting of annotated assignments whose subscript annotation contains |
| 8 |
an inline comment (e.g. `x: list[ # pyright: ignore[...]`) (#5130) |
| 9 |
- Preserve inline comments (including `# type: ignore`) immediately before a |
| 10 |
`# fmt: skip` line, avoiding AST equivalence failures (#5139) |
| 11 |
|
| 12 |
### Packaging |
| 13 |
|
| 14 |
- Correct the version in the published executables (#5137) |
| 15 |
|
| 16 |
### Documentation |
| 17 |
|
| 18 |
- Add Neovim integration guide covering conform.nvim, ALE, and simple command approaches |
| 19 |
(#5124) |
| 20 |
|
| 21 |
## Version 26.5.0 |
| 22 |
|
| 23 |
### Highlights |
| 24 |
|
| 25 |
- Add support for unpacking in comprehensions (PEP 798) and for lazy imports (PEP 810), |
| 26 |
both new syntactic features in Python 3.15 (#5048) |
| 27 |
- Python 3.15 is now supported. Compiled wheels are not yet provided for Python 3.15, so |
| 28 |
performance may be slower than on existing Python versions. Wheels will be provided |
| 29 |
once Python 3.15 is later in its release cycle. (#5127) |
| 30 |
|
| 31 |
### Stable style |
| 32 |
|
| 33 |
- Fix `# fmt: skip` being ignored in nested `if` expressions with parenthesized `in` |
| 34 |
clauses (#4903) |
| 35 |
- Add syntactic support for Python 3.15 (#5048) |
| 36 |
- Fix crash when an f-string follows a `# fmt: off` comment inside brackets (#5097) |
| 37 |
- Preserve multiline compound statement headers when `# fmt: skip` is placed on the |
| 38 |
colon line (#5117) |
| 39 |
|
| 40 |
### Preview style |
| 41 |
|
| 42 |
- Improve heuristics around whether blank lines should appear before, within and after |
| 43 |
groups of same-name decorated functions (such as `@overload` groups) in `.pyi` stub |
| 44 |
files (#5021) |
| 45 |
- Fix blank lines being removed between a function and a decorated class in `.pyi` stub |
| 46 |
files (#5092) |
| 47 |
- Prevent string merger from creating unsplittable long lines when a pragma comment |
| 48 |
(e.g. `# type: ignore`) follows the closing bracket (#5096) |
| 49 |
|
| 50 |
### Packaging |
| 51 |
|
| 52 |
- Run CI on 3.15 (#5127) |
| 53 |
|
| 54 |
### Output |
| 55 |
|
| 56 |
- Improve parse error readability by showing multi-line output with an error pointer. |
| 57 |
(#5068) |
| 58 |
- Add `SourceASTParseError` to distinguish source parse failures from internal safety |
| 59 |
errors, improving error reporting when Black's lenient parser accepts input that |
| 60 |
`ast.parse()` rejects (#5080) |
| 61 |
|
| 62 |
### _Blackd_ |
| 63 |
|
| 64 |
- Return HTTP 400 (Bad Request) for source parse failures instead of HTTP 500, keeping |
| 65 |
HTTP 500 only for genuine internal safety errors (#5080) |
| 66 |
|
| 67 |
### Integrations |
| 68 |
|
| 69 |
- Added documentation for doctest formatting tools and updated the integrations index to |
| 70 |
match (#4916) |
| 71 |
|
| 72 |
### Documentation |
| 73 |
|
| 74 |
- Use "Version X.Y.Z" headings in changelog for stable permalink anchors on ReadTheDocs |
| 75 |
(#5063) |
| 76 |
- Note in the editor integrations that the SublimeText `sublack` plugin is archived and |
| 77 |
unmaintained (#5082) |
| 78 |
|
| 79 |
## Version 26.3.1 |
| 80 |
|
| 81 |
### Stable style |
| 82 |
|
| 83 |
- Prevent Jupyter notebook magic masking collisions from corrupting cells by using |
| 84 |
exact-length placeholders for short magics and aborting if a placeholder can no longer |
| 85 |
be unmasked safely (#5038) |
| 86 |
|
| 87 |
### Configuration |
| 88 |
|
| 89 |
- Always hash cache filename components derived from `--python-cell-magics` so custom |
| 90 |
magic names cannot affect cache paths (#5038) |
| 91 |
|
| 92 |
### _Blackd_ |
| 93 |
|
| 94 |
- Disable browser-originated requests by default, add configurable origin allowlisting |
| 95 |
and request body limits, and bound executor submissions to improve backpressure |
| 96 |
(#5039) |
| 97 |
|
| 98 |
## Version 26.3.0 |
| 99 |
|
| 100 |
### Stable style |
| 101 |
|
| 102 |
- Don't double-decode input, causing non-UTF-8 files to be corrupted (#4964) |
| 103 |
- Fix crash on standalone comment in lambda default arguments (#4993) |
| 104 |
- Preserve parentheses when `# type: ignore` comments would be merged with other |
| 105 |
comments on the same line, preventing AST equivalence failures (#4888) |
| 106 |
|
| 107 |
### Preview style |
| 108 |
|
| 109 |
- Fix bug where `if` guards in `case` blocks were incorrectly split when the pattern had |
| 110 |
a trailing comma (#4884) |
| 111 |
- Fix `string_processing` crashing on unassigned long string literals with trailing |
| 112 |
commas (one-item tuples) (#4929) |
| 113 |
- Simplify implementation of the power operator "hugging" logic (#4918) |
| 114 |
|
| 115 |
### Packaging |
| 116 |
|
| 117 |
- Fix shutdown errors in PyInstaller builds on macOS by disabling multiprocessing in |
| 118 |
frozen environments (#4930) |
| 119 |
|
| 120 |
### Performance |
| 121 |
|
| 122 |
- Introduce winloop for windows as an alternative to uvloop (#4996) |
| 123 |
- Remove deprecated function `uvloop.install()` in favor of `uvloop.new_event_loop()` |
| 124 |
(#4996) |
| 125 |
- Rename `maybe_install_uvloop` function to `maybe_use_uvloop` to simplify loop |
| 126 |
installation and creation of either a uvloop/winloop eventloop or default eventloop |
| 127 |
(#4996) |
| 128 |
|
| 129 |
### Output |
| 130 |
|
| 131 |
- Emit a clear warning when the target Python version is newer than the running Python |
| 132 |
version, since AST safety checks cannot parse newer syntax. Also replace the |
| 133 |
misleading "INTERNAL ERROR" message with an actionable error explaining the version |
| 134 |
mismatch (#4983) |
| 135 |
|
| 136 |
### _Blackd_ |
| 137 |
|
| 138 |
- Introduce winloop to be used when windows in use which enables blackd to run faster on |
| 139 |
windows when winloop is installed. (#4996) |
| 140 |
|
| 141 |
### Integrations |
| 142 |
|
| 143 |
- Remove unused gallery script (#5030) |
| 144 |
- Harden parsing of `black` requirements in the GitHub Action when `use_pyproject` is |
| 145 |
enabled so that only version specifiers are accepted and direct references such as |
| 146 |
`black @ https://...` are rejected. Users should upgrade to the latest version of the |
| 147 |
action as soon as possible. This update is received automatically when using |
| 148 |
`psf/black@stable`, and is independent of the version of Black installed by the |
| 149 |
action. (#5031) |
| 150 |
|
| 151 |
### Documentation |
| 152 |
|
| 153 |
- Expand preview style documentation with detailed examples for `wrap_comprehension_in`, |
| 154 |
`simplify_power_operator_hugging`, and `wrap_long_dict_values_in_parens` features |
| 155 |
(#4987) |
| 156 |
- Add detailed documentation for formatting Jupyter Notebooks (#5009) |
| 157 |
|
| 158 |
## Version 26.1.0 |
| 159 |
|
| 160 |
### Highlights |
| 161 |
|
| 162 |
Introduces the 2026 stable style (#4892), stabilizing the following changes: |
| 163 |
|
| 164 |
- `always_one_newline_after_import`: Always force one blank line after import |
| 165 |
statements, except when the line after the import is a comment or an import statement |
| 166 |
(#4489) |
| 167 |
- `fix_fmt_skip_in_one_liners`: Fix `# fmt: skip` behavior on one-liner declarations, |
| 168 |
such as `def foo(): return "mock" # fmt: skip`, where previously the declaration would |
| 169 |
have been incorrectly collapsed (#4800) |
| 170 |
- `fix_module_docstring_detection`: Fix module docstrings being treated as normal |
| 171 |
strings if preceded by comments (#4764) |
| 172 |
- `fix_type_expansion_split`: Fix type expansions split in generic functions (#4777) |
| 173 |
- `multiline_string_handling`: Make expressions involving multiline strings more compact |
| 174 |
(#1879) |
| 175 |
- `normalize_cr_newlines`: Add `\r` style newlines to the potential newlines to |
| 176 |
normalize file newlines both from and to (#4710) |
| 177 |
- `remove_parens_around_except_types`: Remove parentheses around multiple exception |
| 178 |
types in `except` and `except*` without `as` (#4720) |
| 179 |
- `remove_parens_from_assignment_lhs`: Remove unnecessary parentheses from the left-hand |
| 180 |
side of assignments while preserving magic trailing commas and intentional multiline |
| 181 |
formatting (#4865) |
| 182 |
- `standardize_type_comments`: Format type comments which have zero or more spaces |
| 183 |
between `#` and `type:` or between `type:` and value to `# type: (value)` (#4645) |
| 184 |
|
| 185 |
The following change was not in any previous stable release: |
| 186 |
|
| 187 |
- Regenerated the `_width_table.py` and added tests for the Khmer language (#4253) |
| 188 |
|
| 189 |
This release alo bumps `pathspec` to v1 and fixes inconsistencies with Git's |
| 190 |
`.gitignore` logic (#4958). Now, files will be ignored if a pattern matches them, even |
| 191 |
if the parent directory is directly unignored. For example, Black would previously |
| 192 |
format `exclude/not_this/foo.py` with this `.gitignore`: |
| 193 |
|
| 194 |
``` |
| 195 |
exclude/ |
| 196 |
!exclude/not_this/ |
| 197 |
``` |
| 198 |
|
| 199 |
Now, `exclude/not_this/foo.py` will remain ignored. To ensure `exclude/not_this/` and |
| 200 |
all of it's children are included in formatting (and in Git), use this `.gitignore`: |
| 201 |
|
| 202 |
``` |
| 203 |
*/exclude/* |
| 204 |
!*/exclude/not_this/ |
| 205 |
``` |
| 206 |
|
| 207 |
This new behavior matches Git. The leading `*/` are only necessary if you wish to ignore |
| 208 |
matching subdirectories (like the previous behavior did), and not just matching root |
| 209 |
directories. |
| 210 |
|
| 211 |
### Output |
| 212 |
|
| 213 |
- Explicitly shutdown the multiprocessing manager when run in diff mode too (#4952) |
| 214 |
|
| 215 |
### Integrations |
| 216 |
|
| 217 |
- Upgraded PyPI upload workflow to use Trusted Publishing (#4611) |
| 218 |
|
| 219 |
## Version 25.12.0 |
| 220 |
|
| 221 |
### Highlights |
| 222 |
|
| 223 |
- Black no longer supports running with Python 3.9 (#4842) |
| 224 |
|
| 225 |
### Stable style |
| 226 |
|
| 227 |
- Fix bug where comments preceding `# fmt: off`/`# fmt: on` blocks were incorrectly |
| 228 |
removed, particularly affecting Jupytext's `# %% [markdown]` comments (#4845) |
| 229 |
- Fix crash when multiple `# fmt: skip` comments are used in a multi-part if-clause, on |
| 230 |
string literals, or on dictionary entries with long lines (#4872) |
| 231 |
- Fix possible crash when `fmt: ` directives aren't on the top level (#4856) |
| 232 |
|
| 233 |
### Preview style |
| 234 |
|
| 235 |
- Fix `fmt: skip` skipping the line after instead of the line it's on (#4855) |
| 236 |
- Remove unnecessary parentheses from the left-hand side of assignments while preserving |
| 237 |
magic trailing commas and intentional multiline formatting (#4865) |
| 238 |
- Fix `fix_fmt_skip_in_one_liners` crashing on `with` statements (#4853) |
| 239 |
- Fix `fix_fmt_skip_in_one_liners` crashing on annotated parameters (#4854) |
| 240 |
- Fix new lines being added after imports with `# fmt: skip` on them (#4894) |
| 241 |
|
| 242 |
### Packaging |
| 243 |
|
| 244 |
- Releases now include arm64 Windows binaries and wheels (#4814) |
| 245 |
|
| 246 |
### Integrations |
| 247 |
|
| 248 |
- Add `output-file` input to GitHub Action `psf/black` to write formatter output to a |
| 249 |
file for artifact capture and log cleanliness (#4824) |
| 250 |
|
| 251 |
## Version 25.11.0 |
| 252 |
|
| 253 |
### Highlights |
| 254 |
|
| 255 |
- Enable base 3.14 support (#4804) |
| 256 |
- Add support for the new Python 3.14 t-string syntax introduced by PEP 750 (#4805) |
| 257 |
|
| 258 |
### Stable style |
| 259 |
|
| 260 |
- Fix bug where comments between `# fmt: off` and `# fmt: on` were reformatted (#4811) |
| 261 |
- Comments containing fmt directives now preserve their exact formatting instead of |
| 262 |
being normalized (#4811) |
| 263 |
|
| 264 |
### Preview style |
| 265 |
|
| 266 |
- Move `multiline_string_handling` from `--unstable` to `--preview` (#4760) |
| 267 |
- Fix bug where module docstrings would be treated as normal strings if preceded by |
| 268 |
comments (#4764) |
| 269 |
- Fix bug where python 3.12 generics syntax split line happens weirdly (#4777) |
| 270 |
- Standardize type comments to form `# type: <value>` (#4645) |
| 271 |
- Fix `fix_fmt_skip_in_one_liners` preview feature to respect `# fmt: skip` for compound |
| 272 |
statements with semicolon-separated bodies (#4800) |
| 273 |
|
| 274 |
### Configuration |
| 275 |
|
| 276 |
- Add `no_cache` option to control caching behavior. (#4803) |
| 277 |
|
| 278 |
### Packaging |
| 279 |
|
| 280 |
- Releases now include arm64 Linux binaries (#4773) |
| 281 |
|
| 282 |
### Output |
| 283 |
|
| 284 |
- Write unchanged content to stdout when excluding formatting from stdin using pipes |
| 285 |
(#4610) |
| 286 |
|
| 287 |
### _Blackd_ |
| 288 |
|
| 289 |
- Implemented BlackDClient. This simple python client allows to easily send formatting |
| 290 |
requests to blackd (#4774) |
| 291 |
|
| 292 |
### Integrations |
| 293 |
|
| 294 |
- Enable 3.14 base CI (#4804) |
| 295 |
- Enhance GitHub Action `psf/black` to support the `required-version` major-version-only |
| 296 |
"stability" format when using pyproject.toml (#4770) |
| 297 |
- Improve error message for vim plugin users. It now handles independently vim version |
| 298 |
- Vim: Warn on unsupported Vim and Python versions independently (#4772) |
| 299 |
- Vim: Print the import paths when importing black fails (#4675) |
| 300 |
- Vim: Fix handling of virtualenvs that have a different Python version (#4675) |
| 301 |
|
| 302 |
## Version 25.9.0 |
| 303 |
|
| 304 |
### Highlights |
| 305 |
|
| 306 |
- Remove support for pre-python 3.7 `await/async` as soft keywords/variable names |
| 307 |
(#4676) |
| 308 |
|
| 309 |
### Stable style |
| 310 |
|
| 311 |
- Fix crash while formatting a long `del` statement containing tuples (#4628) |
| 312 |
- Fix crash while formatting expressions using the walrus operator in complex `with` |
| 313 |
statements (#4630) |
| 314 |
- Handle `# fmt: skip` followed by a comment at the end of file (#4635) |
| 315 |
- Fix crash when a tuple appears in the `as` clause of a `with` statement (#4634) |
| 316 |
- Fix crash when tuple is used as a context manager inside a `with` statement (#4646) |
| 317 |
- Fix crash when formatting a `\` followed by a `\r` followed by a comment (#4663) |
| 318 |
- Fix crash on a `\\r\n` (#4673) |
| 319 |
- Fix crash on `await ...` (where `...` is a literal `Ellipsis`) (#4676) |
| 320 |
- Fix crash on parenthesized expression inside a type parameter bound (#4684) |
| 321 |
- Fix crash when using line ranges excluding indented single line decorated items |
| 322 |
(#4670) |
| 323 |
|
| 324 |
### Preview style |
| 325 |
|
| 326 |
- Fix a bug where one-liner functions/conditionals marked with `# fmt: skip` would still |
| 327 |
be formatted (#4552) |
| 328 |
- Improve `multiline_string_handling` with ternaries and dictionaries (#4657) |
| 329 |
- Fix a bug where `string_processing` would not split f-strings directly after |
| 330 |
expressions (#4680) |
| 331 |
- Wrap the `in` clause of comprehensions across lines if necessary (#4699) |
| 332 |
- Remove parentheses around multiple exception types in `except` and `except*` without |
| 333 |
`as`. (#4720) |
| 334 |
- Add `\r` style newlines to the potential newlines to normalize file newlines both from |
| 335 |
and to (#4710) |
| 336 |
|
| 337 |
### Parser |
| 338 |
|
| 339 |
- Rewrite tokenizer to improve performance and compliance (#4536) |
| 340 |
- Fix bug where certain unusual expressions (e.g., lambdas) were not accepted in type |
| 341 |
parameter bounds and defaults. (#4602) |
| 342 |
|
| 343 |
### Performance |
| 344 |
|
| 345 |
- Avoid using an extra process when running with only one worker (#4734) |
| 346 |
|
| 347 |
### Integrations |
| 348 |
|
| 349 |
- Fix the version check in the vim file to reject Python 3.8 (#4567) |
| 350 |
- Enhance GitHub Action `psf/black` to read Black version from an additional section in |
| 351 |
pyproject.toml: `[project.dependency-groups]` (#4606) |
| 352 |
- Build gallery docker image with python3-slim and reduce image size (#4686) |
| 353 |
|
| 354 |
### Documentation |
| 355 |
|
| 356 |
- Add FAQ entry for windows emoji not displaying (#4714) |
| 357 |
|
| 358 |
## Version 25.1.0 |
| 359 |
|
| 360 |
### Highlights |
| 361 |
|
| 362 |
This release introduces the new 2025 stable style (#4558), stabilizing the following |
| 363 |
changes: |
| 364 |
|
| 365 |
- Normalize casing of Unicode escape characters in strings to lowercase (#2916) |
| 366 |
- Fix inconsistencies in whether certain strings are detected as docstrings (#4095) |
| 367 |
- Consistently add trailing commas to typed function parameters (#4164) |
| 368 |
- Remove redundant parentheses in if guards for case blocks (#4214) |
| 369 |
- Add parentheses to if clauses in case blocks when the line is too long (#4269) |
| 370 |
- Whitespace before `# fmt: skip` comments is no longer normalized (#4146) |
| 371 |
- Fix line length computation for certain expressions that involve the power operator |
| 372 |
(#4154) |
| 373 |
- Check if there is a newline before the terminating quotes of a docstring (#4185) |
| 374 |
- Fix type annotation spacing between `*` and more complex type variable tuple (#4440) |
| 375 |
|
| 376 |
The following changes were not in any previous release: |
| 377 |
|
| 378 |
- Remove parentheses around sole list items (#4312) |
| 379 |
- Generic function definitions are now formatted more elegantly: parameters are split |
| 380 |
over multiple lines first instead of type parameter definitions (#4553) |
| 381 |
|
| 382 |
### Stable style |
| 383 |
|
| 384 |
- Fix formatting cells in IPython notebooks with magic methods and starting or trailing |
| 385 |
empty lines (#4484) |
| 386 |
- Fix crash when formatting `with` statements containing tuple generators/unpacking |
| 387 |
(#4538) |
| 388 |
|
| 389 |
### Preview style |
| 390 |
|
| 391 |
- Fix/remove string merging changing f-string quotes on f-strings with internal quotes |
| 392 |
(#4498) |
| 393 |
- Collapse multiple empty lines after an import into one (#4489) |
| 394 |
- Prevent `string_processing` and `wrap_long_dict_values_in_parens` from removing |
| 395 |
parentheses around long dictionary values (#4377) |
| 396 |
- Move `wrap_long_dict_values_in_parens` from the unstable to preview style (#4561) |
| 397 |
|
| 398 |
### Packaging |
| 399 |
|
| 400 |
- Store license identifier inside the `License-Expression` metadata field, see |
| 401 |
[PEP 639](https://peps.python.org/pep-0639/). (#4479) |
| 402 |
|
| 403 |
### Performance |
| 404 |
|
| 405 |
- Speed up the `is_fstring_start` function in Black's tokenizer (#4541) |
| 406 |
|
| 407 |
### Integrations |
| 408 |
|
| 409 |
- If using stdin with `--stdin-filename` set to a force excluded path, stdin won't be |
| 410 |
formatted. (#4539) |
| 411 |
|
| 412 |
## Version 24.10.0 |
| 413 |
|
| 414 |
### Highlights |
| 415 |
|
| 416 |
- Black is now officially tested with Python 3.13 and provides Python 3.13 |
| 417 |
mypyc-compiled wheels. (#4436) (#4449) |
| 418 |
- Black will issue an error when used with Python 3.12.5, due to an upstream memory |
| 419 |
safety issue in Python 3.12.5 that can cause Black's AST safety checks to fail. Please |
| 420 |
use Python 3.12.6 or Python 3.12.4 instead. (#4447) |
| 421 |
- Black no longer supports running with Python 3.8 (#4452) |
| 422 |
|
| 423 |
### Stable style |
| 424 |
|
| 425 |
- Fix crashes involving comments in parenthesised return types or `X | Y` style unions. |
| 426 |
(#4453) |
| 427 |
- Fix skipping Jupyter cells with unknown `%%` magic (#4462) |
| 428 |
|
| 429 |
### Preview style |
| 430 |
|
| 431 |
- Fix type annotation spacing between * and more complex type variable tuple (i.e. `def |
| 432 |
fn(*args: *tuple[*Ts, T]) -> None: pass`) (#4440) |
| 433 |
|
| 434 |
### Caching |
| 435 |
|
| 436 |
- Fix bug where the cache was shared between runs with and without `--unstable` (#4466) |
| 437 |
|
| 438 |
### Packaging |
| 439 |
|
| 440 |
- Upgrade version of mypyc used to 1.12 beta (#4450) (#4449) |
| 441 |
- `blackd` now requires a newer version of aiohttp. (#4451) |
| 442 |
|
| 443 |
### Output |
| 444 |
|
| 445 |
- Added Python target version information on parse error (#4378) |
| 446 |
- Add information about Black version to internal error messages (#4457) |
| 447 |
|
| 448 |
## Version 24.8.0 |
| 449 |
|
| 450 |
### Stable style |
| 451 |
|
| 452 |
- Fix crash when `# fmt: off` is used before a closing parenthesis or bracket. (#4363) |
| 453 |
|
| 454 |
### Packaging |
| 455 |
|
| 456 |
- Packaging metadata updated: docs are explicitly linked, the issue tracker is now also |
| 457 |
linked. This improves the PyPI listing for Black. (#4345) |
| 458 |
|
| 459 |
### Parser |
| 460 |
|
| 461 |
- Fix regression where Black failed to parse a multiline f-string containing another |
| 462 |
multiline string (#4339) |
| 463 |
- Fix regression where Black failed to parse an escaped single quote inside an f-string |
| 464 |
(#4401) |
| 465 |
- Fix bug with Black incorrectly parsing empty lines with a backslash (#4343) |
| 466 |
- Fix bugs with Black's tokenizer not handling `\{` inside f-strings very well (#4422) |
| 467 |
- Fix incorrect line numbers in the tokenizer for certain tokens within f-strings |
| 468 |
(#4423) |
| 469 |
|
| 470 |
### Performance |
| 471 |
|
| 472 |
- Improve performance when a large directory is listed in `.gitignore` (#4415) |
| 473 |
|
| 474 |
### _Blackd_ |
| 475 |
|
| 476 |
- Fix blackd (and all extras installs) for docker container (#4357) |
| 477 |
|
| 478 |
## Version 24.4.2 |
| 479 |
|
| 480 |
This is a bugfix release to fix two regressions in the new f-string parser introduced in |
| 481 |
24.4.1. |
| 482 |
|
| 483 |
### Parser |
| 484 |
|
| 485 |
- Fix regression where certain complex f-strings failed to parse (#4332) |
| 486 |
|
| 487 |
### Performance |
| 488 |
|
| 489 |
- Fix bad performance on certain complex string literals (#4331) |
| 490 |
|
| 491 |
## Version 24.4.1 |
| 492 |
|
| 493 |
### Highlights |
| 494 |
|
| 495 |
- Add support for the new Python 3.12 f-string syntax introduced by PEP 701 (#3822) |
| 496 |
|
| 497 |
### Stable style |
| 498 |
|
| 499 |
- Fix crash involving indented dummy functions containing newlines (#4318) |
| 500 |
|
| 501 |
### Parser |
| 502 |
|
| 503 |
- Add support for type parameter defaults, a new syntactic feature added to Python 3.13 |
| 504 |
by PEP 696 (#4327) |
| 505 |
|
| 506 |
### Integrations |
| 507 |
|
| 508 |
- Github Action now works even when `git archive` is skipped (#4313) |
| 509 |
|
| 510 |
## Version 24.4.0 |
| 511 |
|
| 512 |
### Stable style |
| 513 |
|
| 514 |
- Fix unwanted crashes caused by AST equivalency check (#4290) |
| 515 |
|
| 516 |
### Preview style |
| 517 |
|
| 518 |
- `if` guards in `case` blocks are now wrapped in parentheses when the line is too long. |
| 519 |
(#4269) |
| 520 |
- Stop moving multiline strings to a new line unless inside brackets (#4289) |
| 521 |
|
| 522 |
### Integrations |
| 523 |
|
| 524 |
- Add a new option `use_pyproject` to the GitHub Action `psf/black`. This will read the |
| 525 |
Black version from `pyproject.toml`. (#4294) |
| 526 |
|
| 527 |
## Version 24.3.0 |
| 528 |
|
| 529 |
### Highlights |
| 530 |
|
| 531 |
This release is a milestone: it fixes Black's first CVE security vulnerability. If you |
| 532 |
run Black on untrusted input, or if you habitually put thousands of leading tab |
| 533 |
characters in your docstrings, you are strongly encouraged to upgrade immediately to fix |
| 534 |
[CVE-2024-21503](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503). |
| 535 |
|
| 536 |
This release also fixes a bug in Black's AST safety check that allowed Black to make |
| 537 |
incorrect changes to certain f-strings that are valid in Python 3.12 and higher. |
| 538 |
|
| 539 |
### Stable style |
| 540 |
|
| 541 |
- Don't move comments along with delimiters, which could cause crashes (#4248) |
| 542 |
- Strengthen AST safety check to catch more unsafe changes to strings. Previous versions |
| 543 |
of Black would incorrectly format the contents of certain unusual f-strings containing |
| 544 |
nested strings with the same quote type. Now, Black will crash on such strings until |
| 545 |
support for the new f-string syntax is implemented. (#4270) |
| 546 |
- Fix a bug where line-ranges exceeding the last code line would not work as expected |
| 547 |
(#4273) |
| 548 |
|
| 549 |
### Performance |
| 550 |
|
| 551 |
- Fix catastrophic performance on docstrings that contain large numbers of leading tab |
| 552 |
characters. This fixes |
| 553 |
[CVE-2024-21503](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-21503). |
| 554 |
(#4278) |
| 555 |
|
| 556 |
### Documentation |
| 557 |
|
| 558 |
- Note what happens when `--check` is used with `--quiet` (#4236) |
| 559 |
|
| 560 |
## Version 24.2.0 |
| 561 |
|
| 562 |
### Stable style |
| 563 |
|
| 564 |
- Fixed a bug where comments where mistakenly removed along with redundant parentheses |
| 565 |
(#4218) |
| 566 |
|
| 567 |
### Preview style |
| 568 |
|
| 569 |
- Move the `hug_parens_with_braces_and_square_brackets` feature to the unstable style |
| 570 |
due to an outstanding crash and proposed formatting tweaks (#4198) |
| 571 |
- Fixed a bug where base expressions caused inconsistent formatting of \*\* in ternary |
| 572 |
expression (#4154) |
| 573 |
- Checking for newline before adding one on docstring that is almost at the line limit |
| 574 |
(#4185) |
| 575 |
- Remove redundant parentheses in `case` statement `if` guards (#4214). |
| 576 |
|
| 577 |
### Configuration |
| 578 |
|
| 579 |
- Fix issue where _Black_ would ignore input files in the presence of symlinks (#4222) |
| 580 |
- _Black_ now ignores `pyproject.toml` that is missing a `tool.black` section when |
| 581 |
discovering project root and configuration. Since _Black_ continues to use version |
| 582 |
control as an indicator of project root, this is expected to primarily change behavior |
| 583 |
for users in a monorepo setup (desirably). If you wish to preserve previous behavior, |
| 584 |
simply add an empty `[tool.black]` to the previously discovered `pyproject.toml` |
| 585 |
(#4204) |
| 586 |
|
| 587 |
### Output |
| 588 |
|
| 589 |
- Black will swallow any `SyntaxWarning`s or `DeprecationWarning`s produced by the `ast` |
| 590 |
module when performing equivalence checks (#4189) |
| 591 |
|
| 592 |
### Integrations |
| 593 |
|
| 594 |
- Add a JSONSchema and provide a validate-pyproject entry-point (#4181) |
| 595 |
|
| 596 |
## Version 24.1.1 |
| 597 |
|
| 598 |
Bugfix release to fix a bug that made Black unusable on certain file systems with strict |
| 599 |
limits on path length. |
| 600 |
|
| 601 |
### Preview style |
| 602 |
|
| 603 |
- Consistently add trailing comma on typed parameters (#4164) |
| 604 |
|
| 605 |
### Configuration |
| 606 |
|
| 607 |
- Shorten the length of the name of the cache file to fix crashes on file systems that |
| 608 |
do not support long paths (#4176) |
| 609 |
|
| 610 |
## Version 24.1.0 |
| 611 |
|
| 612 |
### Highlights |
| 613 |
|
| 614 |
This release introduces the new 2024 stable style (#4106), stabilizing the following |
| 615 |
changes: |
| 616 |
|
| 617 |
- Add parentheses around `if`-`else` expressions (#2278) |
| 618 |
- Dummy class and function implementations consisting only of `...` are formatted more |
| 619 |
compactly (#3796) |
| 620 |
- If an assignment statement is too long, we now prefer splitting on the right-hand side |
| 621 |
(#3368) |
| 622 |
- Hex codes in Unicode escape sequences are now standardized to lowercase (#2916) |
| 623 |
- Allow empty first lines at the beginning of most blocks (#3967, #4061) |
| 624 |
- Add parentheses around long type annotations (#3899) |
| 625 |
- Enforce newline after module docstrings (#3932, #4028) |
| 626 |
- Fix incorrect magic trailing comma handling in return types (#3916) |
| 627 |
- Remove blank lines before class docstrings (#3692) |
| 628 |
- Wrap multiple context managers in parentheses if combined in a single `with` statement |
| 629 |
(#3489) |
| 630 |
- Fix bug in line length calculations for power operations (#3942) |
| 631 |
- Add trailing commas to collection literals even if there's a comment after the last |
| 632 |
entry (#3393) |
| 633 |
- When using `--skip-magic-trailing-comma` or `-C`, trailing commas are stripped from |
| 634 |
subscript expressions with more than 1 element (#3209) |
| 635 |
- Add extra blank lines in stubs in a few cases (#3564, #3862) |
| 636 |
- Accept raw strings as docstrings (#3947) |
| 637 |
- Split long lines in case blocks (#4024) |
| 638 |
- Stop removing spaces from walrus operators within subscripts (#3823) |
| 639 |
- Fix incorrect formatting of certain async statements (#3609) |
| 640 |
- Allow combining `# fmt: skip` with other comments (#3959) |
| 641 |
|
| 642 |
There are already a few improvements in the `--preview` style, which are slated for the |
| 643 |
2025 stable style. Try them out and |
| 644 |
[share your feedback](https://github.com/psf/black/issues). In the past, the preview |
| 645 |
style has included some features that we were not able to stabilize. This year, we're |
| 646 |
adding a separate `--unstable` style for features with known problems. Now, the |
| 647 |
`--preview` style only includes features that we actually expect to make it into next |
| 648 |
year's stable style. |
| 649 |
|
| 650 |
### Stable style |
| 651 |
|
| 652 |
Several bug fixes were made in features that are moved to the stable style in this |
| 653 |
release: |
| 654 |
|
| 655 |
- Fix comment handling when parenthesising conditional expressions (#4134) |
| 656 |
- Fix bug where spaces were not added around parenthesized walruses in subscripts, |
| 657 |
unlike other binary operators (#4109) |
| 658 |
- Remove empty lines before docstrings in async functions (#4132) |
| 659 |
- Address a missing case in the change to allow empty lines at the beginning of all |
| 660 |
blocks, except immediately before a docstring (#4130) |
| 661 |
- For stubs, fix logic to enforce empty line after nested classes with bodies (#4141) |
| 662 |
|
| 663 |
### Preview style |
| 664 |
|
| 665 |
- Add `--unstable` style, covering preview features that have known problems that would |
| 666 |
block them from going into the stable style. Also add the `--enable-unstable-feature` |
| 667 |
flag; for example, use |
| 668 |
`--enable-unstable-feature hug_parens_with_braces_and_square_brackets` to apply this |
| 669 |
preview feature throughout 2024, even if a later Black release downgrades the feature |
| 670 |
to unstable (#4096) |
| 671 |
- Format module docstrings the same as class and function docstrings (#4095) |
| 672 |
- Fix crash when using a walrus in a dictionary (#4155) |
| 673 |
- Fix unnecessary parentheses when wrapping long dicts (#4135) |
| 674 |
- Stop normalizing spaces before `# fmt: skip` comments (#4146) |
| 675 |
|
| 676 |
### Configuration |
| 677 |
|
| 678 |
- Print warning when configuration in `pyproject.toml` contains an invalid key (#4165) |
| 679 |
- Fix symlink handling, properly ignoring symlinks that point outside of root (#4161) |
| 680 |
- Fix cache mtime logic that resulted in false positive cache hits (#4128) |
| 681 |
- Remove the long-deprecated `--experimental-string-processing` flag. This feature can |
| 682 |
currently be enabled with `--preview --enable-unstable-feature string_processing`. |
| 683 |
(#4096) |
| 684 |
|
| 685 |
### Integrations |
| 686 |
|
| 687 |
- Revert the change to run Black's pre-commit integration only on specific git hooks |
| 688 |
(#3940) for better compatibility with older versions of pre-commit (#4137) |
| 689 |
|
| 690 |
## Version 23.12.1 |
| 691 |
|
| 692 |
### Packaging |
| 693 |
|
| 694 |
- Fixed a bug that included dependencies from the `d` extra by default (#4108) |
| 695 |
|
| 696 |
## Version 23.12.0 |
| 697 |
|
| 698 |
### Highlights |
| 699 |
|
| 700 |
It's almost 2024, which means it's time for a new edition of _Black_'s stable style! |
| 701 |
Together with this release, we'll put out an alpha release 24.1a1 showcasing the draft |
| 702 |
2024 stable style, which we'll finalize in the January release. Please try it out and |
| 703 |
[share your feedback](https://github.com/psf/black/issues/4042). |
| 704 |
|
| 705 |
This release (23.12.0) will still produce the 2023 style. Most but not all of the |
| 706 |
changes in `--preview` mode will be in the 2024 stable style. |
| 707 |
|
| 708 |
### Stable style |
| 709 |
|
| 710 |
- Fix bug where `# fmt: off` automatically dedents when used with the `--line-ranges` |
| 711 |
option, even when it is not within the specified line range. (#4084) |
| 712 |
- Fix feature detection for parenthesized context managers (#4104) |
| 713 |
|
| 714 |
### Preview style |
| 715 |
|
| 716 |
- Prefer more equal signs before a break when splitting chained assignments (#4010) |
| 717 |
- Standalone form feed characters at the module level are no longer removed (#4021) |
| 718 |
- Additional cases of immediately nested tuples, lists, and dictionaries are now |
| 719 |
indented less (#4012) |
| 720 |
- Allow empty lines at the beginning of all blocks, except immediately before a |
| 721 |
docstring (#4060) |
| 722 |
- Fix crash in preview mode when using a short `--line-length` (#4086) |
| 723 |
- Keep suites consisting of only an ellipsis on their own lines if they are not |
| 724 |
functions or class definitions (#4066) (#4103) |
| 725 |
|
| 726 |
### Configuration |
| 727 |
|
| 728 |
- `--line-ranges` now skips _Black_'s internal stability check in `--safe` mode. This |
| 729 |
avoids a crash on rare inputs that have many unformatted same-content lines. (#4034) |
| 730 |
|
| 731 |
### Packaging |
| 732 |
|
| 733 |
- Upgrade to mypy 1.7.1 (#4049) (#4069) |
| 734 |
- Faster compiled wheels are now available for CPython 3.12 (#4070) |
| 735 |
|
| 736 |
### Integrations |
| 737 |
|
| 738 |
- Enable 3.12 CI (#4035) |
| 739 |
- Build docker images in parallel (#4054) |
| 740 |
- Build docker images with 3.12 (#4055) |
| 741 |
|
| 742 |
## Version 23.11.0 |
| 743 |
|
| 744 |
### Highlights |
| 745 |
|
| 746 |
- Support formatting ranges of lines with the new `--line-ranges` command-line option |
| 747 |
(#4020) |
| 748 |
|
| 749 |
### Stable style |
| 750 |
|
| 751 |
- Fix crash on formatting bytes strings that look like docstrings (#4003) |
| 752 |
- Fix crash when whitespace followed a backslash before newline in a docstring (#4008) |
| 753 |
- Fix standalone comments inside complex blocks crashing Black (#4016) |
| 754 |
- Fix crash on formatting code like `await (a ** b)` (#3994) |
| 755 |
- No longer treat leading f-strings as docstrings. This matches Python's behaviour and |
| 756 |
fixes a crash (#4019) |
| 757 |
|
| 758 |
### Preview style |
| 759 |
|
| 760 |
- Multiline dicts and lists that are the sole argument to a function are now indented |
| 761 |
less (#3964) |
| 762 |
- Multiline unpacked dicts and lists as the sole argument to a function are now also |
| 763 |
indented less (#3992) |
| 764 |
- In f-string debug expressions, quote types that are visible in the final string are |
| 765 |
now preserved (#4005) |
| 766 |
- Fix a bug where long `case` blocks were not split into multiple lines. Also enable |
| 767 |
general trailing comma rules on `case` blocks (#4024) |
| 768 |
- Keep requiring two empty lines between module-level docstring and first function or |
| 769 |
class definition (#4028) |
| 770 |
- Add support for single-line format skip with other comments on the same line (#3959) |
| 771 |
|
| 772 |
### Configuration |
| 773 |
|
| 774 |
- Consistently apply force exclusion logic before resolving symlinks (#4015) |
| 775 |
- Fix a bug in the matching of absolute path names in `--include` (#3976) |
| 776 |
|
| 777 |
### Performance |
| 778 |
|
| 779 |
- Fix mypyc builds on arm64 on macOS (#4017) |
| 780 |
|
| 781 |
### Integrations |
| 782 |
|
| 783 |
- Black's pre-commit integration will now run only on git hooks appropriate for a code |
| 784 |
formatter (#3940) |
| 785 |
|
| 786 |
## Version 23.10.1 |
| 787 |
|
| 788 |
### Highlights |
| 789 |
|
| 790 |
- Maintenance release to get a fix out for GitHub Action edge case (#3957) |
| 791 |
|
| 792 |
### Preview style |
| 793 |
|
| 794 |
- Fix merging implicit multiline strings that have inline comments (#3956) |
| 795 |
- Allow empty first line after block open before a comment or compound statement (#3967) |
| 796 |
|
| 797 |
### Packaging |
| 798 |
|
| 799 |
- Change Dockerfile to hatch + compile black (#3965) |
| 800 |
|
| 801 |
### Integrations |
| 802 |
|
| 803 |
- The summary output for GitHub workflows is now suppressible using the `summary` |
| 804 |
parameter. (#3958) |
| 805 |
- Fix the action failing when Black check doesn't pass (#3957) |
| 806 |
|
| 807 |
### Documentation |
| 808 |
|
| 809 |
- It is known Windows documentation CI is broken |
| 810 |
https://github.com/psf/black/issues/3968 |
| 811 |
|
| 812 |
## Version 23.10.0 |
| 813 |
|
| 814 |
### Stable style |
| 815 |
|
| 816 |
- Fix comments getting removed from inside parenthesized strings (#3909) |
| 817 |
|
| 818 |
### Preview style |
| 819 |
|
| 820 |
- Fix long lines with power operators getting split before the line length (#3942) |
| 821 |
- Long type hints are now wrapped in parentheses and properly indented when split across |
| 822 |
multiple lines (#3899) |
| 823 |
- Magic trailing commas are now respected in return types. (#3916) |
| 824 |
- Require one empty line after module-level docstrings. (#3932) |
| 825 |
- Treat raw triple-quoted strings as docstrings (#3947) |
| 826 |
|
| 827 |
### Configuration |
| 828 |
|
| 829 |
- Fix cache versioning logic when `BLACK_CACHE_DIR` is set (#3937) |
| 830 |
|
| 831 |
### Parser |
| 832 |
|
| 833 |
- Fix bug where attributes named `type` were not accepted inside `match` statements |
| 834 |
(#3950) |
| 835 |
- Add support for PEP 695 type aliases containing lambdas and other unusual expressions |
| 836 |
(#3949) |
| 837 |
|
| 838 |
### Output |
| 839 |
|
| 840 |
- Black no longer attempts to provide special errors for attempting to format Python 2 |
| 841 |
code (#3933) |
| 842 |
- Black will more consistently print stacktraces on internal errors in verbose mode |
| 843 |
(#3938) |
| 844 |
|
| 845 |
### Integrations |
| 846 |
|
| 847 |
- The action output displayed in the job summary is now wrapped in Markdown (#3914) |
| 848 |
|
| 849 |
## Version 23.9.1 |
| 850 |
|
| 851 |
Due to various issues, the previous release (23.9.0) did not include compiled mypyc |
| 852 |
wheels, which make Black significantly faster. These issues have now been fixed, and |
| 853 |
this release should come with compiled wheels once again. |
| 854 |
|
| 855 |
There will be no wheels for Python 3.12 due to a bug in mypyc. We will provide 3.12 |
| 856 |
wheels in a future release as soon as the mypyc bug is fixed. |
| 857 |
|
| 858 |
### Packaging |
| 859 |
|
| 860 |
- Upgrade to mypy 1.5.1 (#3864) |
| 861 |
|
| 862 |
### Performance |
| 863 |
|
| 864 |
- Store raw tuples instead of NamedTuples in Black's cache, improving performance and |
| 865 |
decreasing the size of the cache (#3877) |
| 866 |
|
| 867 |
## Version 23.9.0 |
| 868 |
|
| 869 |
### Preview style |
| 870 |
|
| 871 |
- More concise formatting for dummy implementations (#3796) |
| 872 |
- In stub files, add a blank line between a statement with a body (e.g an |
| 873 |
`if sys.version_info > (3, x):`) and a function definition on the same level (#3862) |
| 874 |
- Fix a bug whereby spaces were removed from walrus operators within subscript(#3823) |
| 875 |
|
| 876 |
### Configuration |
| 877 |
|
| 878 |
- Black now applies exclusion and ignore logic before resolving symlinks (#3846) |
| 879 |
|
| 880 |
### Performance |
| 881 |
|
| 882 |
- Avoid importing `IPython` if notebook cells do not contain magics (#3782) |
| 883 |
- Improve caching by comparing file hashes as fallback for mtime and size (#3821) |
| 884 |
|
| 885 |
### _Blackd_ |
| 886 |
|
| 887 |
- Fix an issue in `blackd` with single character input (#3558) |
| 888 |
|
| 889 |
### Integrations |
| 890 |
|
| 891 |
- Black now has an |
| 892 |
[official pre-commit mirror](https://github.com/psf/black-pre-commit-mirror). Swapping |
| 893 |
`https://github.com/psf/black` to `https://github.com/psf/black-pre-commit-mirror` in |
| 894 |
your `.pre-commit-config.yaml` will make Black about 2x faster (#3828) |
| 895 |
- The `.black.env` folder specified by `ENV_PATH` will now be removed on the completion |
| 896 |
of the GitHub Action (#3759) |
| 897 |
|
| 898 |
## Version 23.7.0 |
| 899 |
|
| 900 |
### Highlights |
| 901 |
|
| 902 |
- Runtime support for Python 3.7 has been removed. Formatting 3.7 code will still be |
| 903 |
supported until further notice (#3765) |
| 904 |
|
| 905 |
### Stable style |
| 906 |
|
| 907 |
- Fix a bug where an illegal trailing comma was added to return type annotations using |
| 908 |
PEP 604 unions (#3735) |
| 909 |
- Fix several bugs and crashes where comments in stub files were removed or mishandled |
| 910 |
under some circumstances (#3745) |
| 911 |
- Fix a crash with multi-line magic comments like `type: ignore` within parentheses |
| 912 |
(#3740) |
| 913 |
- Fix error in AST validation when _Black_ removes trailing whitespace in a type comment |
| 914 |
(#3773) |
| 915 |
|
| 916 |
### Preview style |
| 917 |
|
| 918 |
- Implicitly concatenated strings used as function args are no longer wrapped inside |
| 919 |
parentheses (#3640) |
| 920 |
- Remove blank lines between a class definition and its docstring (#3692) |
| 921 |
|
| 922 |
### Configuration |
| 923 |
|
| 924 |
- The `--workers` argument to _Black_ can now be specified via the `BLACK_NUM_WORKERS` |
| 925 |
environment variable (#3743) |
| 926 |
- `.pytest_cache`, `.ruff_cache` and `.vscode` are now excluded by default (#3691) |
| 927 |
- Fix _Black_ not honouring `pyproject.toml` settings when running `--stdin-filename` |
| 928 |
and the `pyproject.toml` found isn't in the current working directory (#3719) |
| 929 |
- _Black_ will now error if `exclude` and `extend-exclude` have invalid data types in |
| 930 |
`pyproject.toml`, instead of silently doing the wrong thing (#3764) |
| 931 |
|
| 932 |
### Packaging |
| 933 |
|
| 934 |
- Upgrade mypyc from 0.991 to 1.3 (#3697) |
| 935 |
- Remove patching of Click that mitigated errors on Python 3.6 with `LANG=C` (#3768) |
| 936 |
|
| 937 |
### Parser |
| 938 |
|
| 939 |
- Add support for the new PEP 695 syntax in Python 3.12 (#3703) |
| 940 |
|
| 941 |
### Performance |
| 942 |
|
| 943 |
- Speed up _Black_ significantly when the cache is full (#3751) |
| 944 |
- Avoid importing `IPython` in a case where we wouldn't need it (#3748) |
| 945 |
|
| 946 |
### Output |
| 947 |
|
| 948 |
- Use aware UTC datetimes internally, avoids deprecation warning on Python 3.12 (#3728) |
| 949 |
- Change verbose logging to exactly mirror _Black_'s logic for source discovery (#3749) |
| 950 |
|
| 951 |
### _Blackd_ |
| 952 |
|
| 953 |
- The `blackd` argument parser now shows the default values for options in their help |
| 954 |
text (#3712) |
| 955 |
|
| 956 |
### Integrations |
| 957 |
|
| 958 |
- Black is now tested with |
| 959 |
[`PYTHONWARNDEFAULTENCODING = 1`](https://docs.python.org/3/library/io.html#io-encoding-warning) |
| 960 |
(#3763) |
| 961 |
- Update GitHub Action to display black output in the job summary (#3688) |
| 962 |
|
| 963 |
### Documentation |
| 964 |
|
| 965 |
- Add a CITATION.cff file to the root of the repository, containing metadata on how to |
| 966 |
cite this software (#3723) |
| 967 |
- Update the _classes_ and _exceptions_ documentation in Developer reference to match |
| 968 |
the latest code base (#3755) |
| 969 |
|
| 970 |
## Version 23.3.0 |
| 971 |
|
| 972 |
### Highlights |
| 973 |
|
| 974 |
This release fixes a longstanding confusing behavior in Black's GitHub action, where the |
| 975 |
version of the action did not determine the version of Black being run (issue #3382). In |
| 976 |
addition, there is a small bug fix around imports and a number of improvements to the |
| 977 |
preview style. |
| 978 |
|
| 979 |
Please try out the |
| 980 |
[preview style](https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#preview-style) |
| 981 |
with `black --preview` and tell us your feedback. All changes in the preview style are |
| 982 |
expected to become part of Black's stable style in January 2024. |
| 983 |
|
| 984 |
### Stable style |
| 985 |
|
| 986 |
- Import lines with `# fmt: skip` and `# fmt: off` no longer have an extra blank line |
| 987 |
added when they are right after another import line (#3610) |
| 988 |
|
| 989 |
### Preview style |
| 990 |
|
| 991 |
- Add trailing commas to collection literals even if there's a comment after the last |
| 992 |
entry (#3393) |
| 993 |
- `async def`, `async for`, and `async with` statements are now formatted consistently |
| 994 |
compared to their non-async version. (#3609) |
| 995 |
- `with` statements that contain two context managers will be consistently wrapped in |
| 996 |
parentheses (#3589) |
| 997 |
- Let string splitters respect [East Asian Width](https://www.unicode.org/reports/tr11/) |
| 998 |
(#3445) |
| 999 |
- Now long string literals can be split after East Asian commas and periods (`、` U+3001 |
| 1000 |
IDEOGRAPHIC COMMA, `。` U+3002 IDEOGRAPHIC FULL STOP, & `,` U+FF0C FULLWIDTH COMMA) |
| 1001 |
besides before spaces (#3445) |
| 1002 |
- For stubs, enforce one blank line after a nested class with a body other than just |
| 1003 |
`...` (#3564) |
| 1004 |
- Improve handling of multiline strings by changing line split behavior (#1879) |
| 1005 |
|
| 1006 |
### Parser |
| 1007 |
|
| 1008 |
- Added support for formatting files with invalid type comments (#3594) |
| 1009 |
|
| 1010 |
### Integrations |
| 1011 |
|
| 1012 |
- Update GitHub Action to use the version of Black equivalent to action's version if |
| 1013 |
version input is not specified (#3543) |
| 1014 |
- Fix missing Python binary path in autoload script for vim (#3508) |
| 1015 |
|
| 1016 |
### Documentation |
| 1017 |
|
| 1018 |
- Document that only the most recent release is supported for security issues; |
| 1019 |
vulnerabilities should be reported through Tidelift (#3612) |
| 1020 |
|
| 1021 |
## Version 23.1.0 |
| 1022 |
|
| 1023 |
### Highlights |
| 1024 |
|
| 1025 |
This is the first release of 2023, and following our |
| 1026 |
[stability policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy), |
| 1027 |
it comes with a number of improvements to our stable style, including improvements to |
| 1028 |
empty line handling, removal of redundant parentheses in several contexts, and output |
| 1029 |
that highlights implicitly concatenated strings better. |
| 1030 |
|
| 1031 |
There are also many changes to the preview style; try out `black --preview` and give us |
| 1032 |
feedback to help us set the stable style for next year. |
| 1033 |
|
| 1034 |
In addition to style changes, Black now automatically infers the supported Python |
| 1035 |
versions from your `pyproject.toml` file, removing the need to set Black's target |
| 1036 |
versions separately. |
| 1037 |
|
| 1038 |
### Stable style |
| 1039 |
|
| 1040 |
- Introduce the 2023 stable style, which incorporates most aspects of last year's |
| 1041 |
preview style (#3418). Specific changes: |
| 1042 |
- Enforce empty lines before classes and functions with sticky leading comments |
| 1043 |
(#3302) (22.12.0) |
| 1044 |
- Reformat empty and whitespace-only files as either an empty file (if no newline is |
| 1045 |
present) or as a single newline character (if a newline is present) (#3348) |
| 1046 |
(22.12.0) |
| 1047 |
- Implicitly concatenated strings used as function args are now wrapped inside |
| 1048 |
parentheses (#3307) (22.12.0) |
| 1049 |
- Correctly handle trailing commas that are inside a line's leading non-nested parens |
| 1050 |
(#3370) (22.12.0) |
| 1051 |
- `--skip-string-normalization` / `-S` now prevents docstring prefixes from being |
| 1052 |
normalized as expected (#3168) (since 22.8.0) |
| 1053 |
- When using `--skip-magic-trailing-comma` or `-C`, trailing commas are stripped from |
| 1054 |
subscript expressions with more than 1 element (#3209) (22.8.0) |
| 1055 |
- Implicitly concatenated strings inside a list, set, or tuple are now wrapped inside |
| 1056 |
parentheses (#3162) (22.8.0) |
| 1057 |
- Fix a string merging/split issue when a comment is present in the middle of |
| 1058 |
implicitly concatenated strings on its own line (#3227) (22.8.0) |
| 1059 |
- Docstring quotes are no longer moved if it would violate the line length limit |
| 1060 |
(#3044, #3430) (22.6.0) |
| 1061 |
- Parentheses around return annotations are now managed (#2990) (22.6.0) |
| 1062 |
- Remove unnecessary parentheses around awaited objects (#2991) (22.6.0) |
| 1063 |
- Remove unnecessary parentheses in `with` statements (#2926) (22.6.0) |
| 1064 |
- Remove trailing newlines after code block open (#3035) (22.6.0) |
| 1065 |
- Code cell separators `#%%` are now standardised to `# %%` (#2919) (22.3.0) |
| 1066 |
- Remove unnecessary parentheses from `except` statements (#2939) (22.3.0) |
| 1067 |
- Remove unnecessary parentheses from tuple unpacking in `for` loops (#2945) (22.3.0) |
| 1068 |
- Avoid magic-trailing-comma in single-element subscripts (#2942) (22.3.0) |
| 1069 |
- Fix a crash when a colon line is marked between `# fmt: off` and `# fmt: on` (#3439) |
| 1070 |
|
| 1071 |
### Preview style |
| 1072 |
|
| 1073 |
- Format hex codes in unicode escape sequences in string literals (#2916) |
| 1074 |
- Add parentheses around `if`-`else` expressions (#2278) |
| 1075 |
- Improve performance on large expressions that contain many strings (#3467) |
| 1076 |
- Fix a crash in preview style with assert + parenthesized string (#3415) |
| 1077 |
- Fix crashes in preview style with walrus operators used in function return annotations |
| 1078 |
and except clauses (#3423) |
| 1079 |
- Fix a crash in preview advanced string processing where mixed implicitly concatenated |
| 1080 |
regular and f-strings start with an empty span (#3463) |
| 1081 |
- Fix a crash in preview advanced string processing where a standalone comment is placed |
| 1082 |
before a dict's value (#3469) |
| 1083 |
- Fix an issue where extra empty lines are added when a decorator has `# fmt: skip` |
| 1084 |
applied or there is a standalone comment between decorators (#3470) |
| 1085 |
- Do not put the closing quotes in a docstring on a separate line, even if the line is |
| 1086 |
too long (#3430) |
| 1087 |
- Long values in dict literals are now wrapped in parentheses; correspondingly |
| 1088 |
unnecessary parentheses around short values in dict literals are now removed; long |
| 1089 |
string lambda values are now wrapped in parentheses (#3440) |
| 1090 |
- Fix two crashes in preview style involving edge cases with docstrings (#3451) |
| 1091 |
- Exclude string type annotations from improved string processing; fix crash when the |
| 1092 |
return type annotation is stringified and spans across multiple lines (#3462) |
| 1093 |
- Wrap multiple context managers in parentheses when targeting Python 3.9+ (#3489) |
| 1094 |
- Fix several crashes in preview style with walrus operators used in `with` statements |
| 1095 |
or tuples (#3473) |
| 1096 |
- Fix an invalid quote escaping bug in f-string expressions where it produced invalid |
| 1097 |
code. Implicitly concatenated f-strings with different quotes can now be merged or |
| 1098 |
quote-normalized by changing the quotes used in expressions. (#3509) |
| 1099 |
- Fix crash on `await (yield)` when Black is compiled with mypyc (#3533) |
| 1100 |
|
| 1101 |
### Configuration |
| 1102 |
|
| 1103 |
- Black now tries to infer its `--target-version` from the project metadata specified in |
| 1104 |
`pyproject.toml` (#3219) |
| 1105 |
|
| 1106 |
### Packaging |
| 1107 |
|
| 1108 |
- Upgrade mypyc from `0.971` to `0.991` so mypycified _Black_ can be built on armv7 |
| 1109 |
(#3380) |
| 1110 |
- This also fixes some crashes while using compiled Black with a debug build of |
| 1111 |
CPython |
| 1112 |
- Drop specific support for the `tomli` requirement on 3.11 alpha releases, working |
| 1113 |
around a bug that would cause the requirement not to be installed on any non-final |
| 1114 |
Python releases (#3448) |
| 1115 |
- Black now depends on `packaging` version `22.0` or later. This is required for new |
| 1116 |
functionality that needs to parse part of the project metadata (#3219) |
| 1117 |
|
| 1118 |
### Output |
| 1119 |
|
| 1120 |
- Calling `black --help` multiple times will return the same help contents each time |
| 1121 |
(#3516) |
| 1122 |
- Verbose logging now shows the values of `pyproject.toml` configuration variables |
| 1123 |
(#3392) |
| 1124 |
- Fix false symlink detection messages in verbose output due to using an incorrect |
| 1125 |
relative path to the project root (#3385) |
| 1126 |
|
| 1127 |
### Integrations |
| 1128 |
|
| 1129 |
- Move 3.11 CI to normal flow now that all dependencies support 3.11 (#3446) |
| 1130 |
- Docker: Add new `latest_prerelease` tag automation to follow latest black alpha |
| 1131 |
release on docker images (#3465) |
| 1132 |
|
| 1133 |
### Documentation |
| 1134 |
|
| 1135 |
- Expand `vim-plug` installation instructions to offer more explicit options (#3468) |
| 1136 |
|
| 1137 |
## Version 22.12.0 |
| 1138 |
|
| 1139 |
### Preview style |
| 1140 |
|
| 1141 |
- Enforce empty lines before classes and functions with sticky leading comments (#3302) |
| 1142 |
- Reformat empty and whitespace-only files as either an empty file (if no newline is |
| 1143 |
present) or as a single newline character (if a newline is present) (#3348) |
| 1144 |
- Implicitly concatenated strings used as function args are now wrapped inside |
| 1145 |
parentheses (#3307) |
| 1146 |
- For assignment statements, prefer splitting the right hand side if the left hand side |
| 1147 |
fits on a single line (#3368) |
| 1148 |
- Correctly handle trailing commas that are inside a line's leading non-nested parens |
| 1149 |
(#3370) |
| 1150 |
|
| 1151 |
### Configuration |
| 1152 |
|
| 1153 |
- Fix incorrectly applied `.gitignore` rules by considering the `.gitignore` location |
| 1154 |
and the relative path to the target file (#3338) |
| 1155 |
- Fix incorrectly ignoring `.gitignore` presence when more than one source directory is |
| 1156 |
specified (#3336) |
| 1157 |
|
| 1158 |
### Parser |
| 1159 |
|
| 1160 |
- Parsing support has been added for walruses inside generator expression that are |
| 1161 |
passed as function args (for example, |
| 1162 |
`any(match := my_re.match(text) for text in texts)`) (#3327). |
| 1163 |
|
| 1164 |
### Integrations |
| 1165 |
|
| 1166 |
- Vim plugin: Optionally allow using the system installation of Black via |
| 1167 |
`let g:black_use_virtualenv = 0`(#3309) |
| 1168 |
|
| 1169 |
## Version 22.10.0 |
| 1170 |
|
| 1171 |
### Highlights |
| 1172 |
|
| 1173 |
- Runtime support for Python 3.6 has been removed. Formatting 3.6 code will still be |
| 1174 |
supported until further notice. |
| 1175 |
|
| 1176 |
### Stable style |
| 1177 |
|
| 1178 |
- Fix a crash when `# fmt: on` is used on a different block level than `# fmt: off` |
| 1179 |
(#3281) |
| 1180 |
|
| 1181 |
### Preview style |
| 1182 |
|
| 1183 |
- Fix a crash when formatting some dicts with parenthesis-wrapped long string keys |
| 1184 |
(#3262) |
| 1185 |
|
| 1186 |
### Configuration |
| 1187 |
|
| 1188 |
- `.ipynb_checkpoints` directories are now excluded by default (#3293) |
| 1189 |
- Add `--skip-source-first-line` / `-x` option to ignore the first line of source code |
| 1190 |
while formatting (#3299) |
| 1191 |
|
| 1192 |
### Packaging |
| 1193 |
|
| 1194 |
- Executables made with PyInstaller will no longer crash when formatting several files |
| 1195 |
at once on macOS. Native x86-64 executables for macOS are available once again. |
| 1196 |
(#3275) |
| 1197 |
- Hatchling is now used as the build backend. This will not have any effect for users |
| 1198 |
who install Black with its wheels from PyPI. (#3233) |
| 1199 |
- Faster compiled wheels are now available for CPython 3.11 (#3276) |
| 1200 |
|
| 1201 |
### _Blackd_ |
| 1202 |
|
| 1203 |
- Windows style (CRLF) newlines will be preserved (#3257). |
| 1204 |
|
| 1205 |
### Integrations |
| 1206 |
|
| 1207 |
- Vim plugin: add flag (`g:black_preview`) to enable/disable the preview style (#3246) |
| 1208 |
- Update GitHub Action to support formatting of Jupyter Notebook files via a `jupyter` |
| 1209 |
option (#3282) |
| 1210 |
- Update GitHub Action to support use of version specifiers (e.g. `<23`) for Black |
| 1211 |
version (#3265) |
| 1212 |
|
| 1213 |
## Version 22.8.0 |
| 1214 |
|
| 1215 |
### Highlights |
| 1216 |
|
| 1217 |
- Python 3.11 is now supported, except for _blackd_ as aiohttp does not support 3.11 as |
| 1218 |
of publishing (#3234) |
| 1219 |
- This is the last release that supports running _Black_ on Python 3.6 (formatting 3.6 |
| 1220 |
code will continue to be supported until further notice) |
| 1221 |
- Reword the stability policy to say that we may, in rare cases, make changes that |
| 1222 |
affect code that was not previously formatted by _Black_ (#3155) |
| 1223 |
|
| 1224 |
### Stable style |
| 1225 |
|
| 1226 |
- Fix an infinite loop when using `# fmt: on/off` in the middle of an expression or code |
| 1227 |
block (#3158) |
| 1228 |
- Fix incorrect handling of `# fmt: skip` on colon (`:`) lines (#3148) |
| 1229 |
- Comments are no longer deleted when a line had spaces removed around power operators |
| 1230 |
(#2874) |
| 1231 |
|
| 1232 |
### Preview style |
| 1233 |
|
| 1234 |
- Single-character closing docstring quotes are no longer moved to their own line as |
| 1235 |
this is invalid. This was a bug introduced in version 22.6.0. (#3166) |
| 1236 |
- `--skip-string-normalization` / `-S` now prevents docstring prefixes from being |
| 1237 |
normalized as expected (#3168) |
| 1238 |
- When using `--skip-magic-trailing-comma` or `-C`, trailing commas are stripped from |
| 1239 |
subscript expressions with more than 1 element (#3209) |
| 1240 |
- Implicitly concatenated strings inside a list, set, or tuple are now wrapped inside |
| 1241 |
parentheses (#3162) |
| 1242 |
- Fix a string merging/split issue when a comment is present in the middle of implicitly |
| 1243 |
concatenated strings on its own line (#3227) |
| 1244 |
|
| 1245 |
### _Blackd_ |
| 1246 |
|
| 1247 |
- `blackd` now supports enabling the preview style via the `X-Preview` header (#3217) |
| 1248 |
|
| 1249 |
### Configuration |
| 1250 |
|
| 1251 |
- Black now uses the presence of debug f-strings to detect target version (#3215) |
| 1252 |
- Fix misdetection of project root and verbose logging of sources in cases involving |
| 1253 |
`--stdin-filename` (#3216) |
| 1254 |
- Immediate `.gitignore` files in source directories given on the command line are now |
| 1255 |
also respected, previously only `.gitignore` files in the project root and |
| 1256 |
automatically discovered directories were respected (#3237) |
| 1257 |
|
| 1258 |
### Documentation |
| 1259 |
|
| 1260 |
- Recommend using BlackConnect in IntelliJ IDEs (#3150) |
| 1261 |
|
| 1262 |
### Integrations |
| 1263 |
|
| 1264 |
- Vim plugin: prefix messages with `Black: ` so it's clear they come from Black (#3194) |
| 1265 |
- Docker: changed to a /opt/venv installation + added to PATH to be available to |
| 1266 |
non-root users (#3202) |
| 1267 |
|
| 1268 |
### Output |
| 1269 |
|
| 1270 |
- Change from deprecated `asyncio.get_event_loop()` to create our event loop which |
| 1271 |
removes DeprecationWarning (#3164) |
| 1272 |
- Remove logging from internal `blib2to3` library since it regularly emits error logs |
| 1273 |
about failed caching that can and should be ignored (#3193) |
| 1274 |
|
| 1275 |
### Parser |
| 1276 |
|
| 1277 |
- Type comments are now included in the AST equivalence check consistently so accidental |
| 1278 |
deletion raises an error. Though type comments can't be tracked when running on PyPy |
| 1279 |
3.7 due to standard library limitations. (#2874) |
| 1280 |
|
| 1281 |
### Performance |
| 1282 |
|
| 1283 |
- Reduce Black's startup time when formatting a single file by 15-30% (#3211) |
| 1284 |
|
| 1285 |
## Version 22.6.0 |
| 1286 |
|
| 1287 |
### Style |
| 1288 |
|
| 1289 |
- Fix unstable formatting involving `#fmt: skip` and `# fmt:skip` comments (notice the |
| 1290 |
lack of spaces) (#2970) |
| 1291 |
|
| 1292 |
### Preview style |
| 1293 |
|
| 1294 |
- Docstring quotes are no longer moved if it would violate the line length limit (#3044) |
| 1295 |
- Parentheses around return annotations are now managed (#2990) |
| 1296 |
- Remove unnecessary parentheses around awaited objects (#2991) |
| 1297 |
- Remove unnecessary parentheses in `with` statements (#2926) |
| 1298 |
- Remove trailing newlines after code block open (#3035) |
| 1299 |
|
| 1300 |
### Integrations |
| 1301 |
|
| 1302 |
- Add `scripts/migrate-black.py` script to ease introduction of Black to a Git project |
| 1303 |
(#3038) |
| 1304 |
|
| 1305 |
### Output |
| 1306 |
|
| 1307 |
- Output Python version and implementation as part of `--version` flag (#2997) |
| 1308 |
|
| 1309 |
### Packaging |
| 1310 |
|
| 1311 |
- Use `tomli` instead of `tomllib` on Python 3.11 builds where `tomllib` is not |
| 1312 |
available (#2987) |
| 1313 |
|
| 1314 |
### Parser |
| 1315 |
|
| 1316 |
- [PEP 654](https://peps.python.org/pep-0654/#except) syntax (for example, |
| 1317 |
`except *ExceptionGroup:`) is now supported (#3016) |
| 1318 |
- [PEP 646](https://peps.python.org/pep-0646) syntax (for example, |
| 1319 |
`Array[Batch, *Shape]` or `def fn(*args: *T) -> None`) is now supported (#3071) |
| 1320 |
|
| 1321 |
### Vim Plugin |
| 1322 |
|
| 1323 |
- Fix `strtobool` function. It didn't parse true/on/false/off. (#3025) |
| 1324 |
|
| 1325 |
## Version 22.3.0 |
| 1326 |
|
| 1327 |
### Preview style |
| 1328 |
|
| 1329 |
- Code cell separators `#%%` are now standardised to `# %%` (#2919) |
| 1330 |
- Remove unnecessary parentheses from `except` statements (#2939) |
| 1331 |
- Remove unnecessary parentheses from tuple unpacking in `for` loops (#2945) |
| 1332 |
- Avoid magic-trailing-comma in single-element subscripts (#2942) |
| 1333 |
|
| 1334 |
### Configuration |
| 1335 |
|
| 1336 |
- Do not format `__pypackages__` directories by default (#2836) |
| 1337 |
- Add support for specifying stable version with `--required-version` (#2832). |
| 1338 |
- Avoid crashing when the user has no homedir (#2814) |
| 1339 |
- Avoid crashing when md5 is not available (#2905) |
| 1340 |
- Fix handling of directory junctions on Windows (#2904) |
| 1341 |
|
| 1342 |
### Documentation |
| 1343 |
|
| 1344 |
- Update pylint config documentation (#2931) |
| 1345 |
|
| 1346 |
### Integrations |
| 1347 |
|
| 1348 |
- Move test to disable plugin in Vim/Neovim, which speeds up loading (#2896) |
| 1349 |
|
| 1350 |
### Output |
| 1351 |
|
| 1352 |
- In verbose mode, log when _Black_ is using user-level config (#2861) |
| 1353 |
|
| 1354 |
### Packaging |
| 1355 |
|
| 1356 |
- Fix Black to work with Click 8.1.0 (#2966) |
| 1357 |
- On Python 3.11 and newer, use the standard library's `tomllib` instead of `tomli` |
| 1358 |
(#2903) |
| 1359 |
- `black-primer`, the deprecated internal devtool, has been removed and copied to a |
| 1360 |
[separate repository](https://github.com/cooperlees/black-primer) (#2924) |
| 1361 |
|
| 1362 |
### Parser |
| 1363 |
|
| 1364 |
- Black can now parse starred expressions in the target of `for` and `async for` |
| 1365 |
statements, e.g `for item in *items_1, *items_2: pass` (#2879). |
| 1366 |
|
| 1367 |
## Version 22.1.0 |
| 1368 |
|
| 1369 |
At long last, _Black_ is no longer a beta product! This is the first non-beta release |
| 1370 |
and the first release covered by our new |
| 1371 |
[stability policy](https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy). |
| 1372 |
|
| 1373 |
### Highlights |
| 1374 |
|
| 1375 |
- **Remove Python 2 support** (#2740) |
| 1376 |
- Introduce the `--preview` flag (#2752) |
| 1377 |
|
| 1378 |
### Style |
| 1379 |
|
| 1380 |
- Deprecate `--experimental-string-processing` and move the functionality under |
| 1381 |
`--preview` (#2789) |
| 1382 |
- For stubs, one blank line between class attributes and methods is now kept if there's |
| 1383 |
at least one pre-existing blank line (#2736) |
| 1384 |
- Black now normalizes string prefix order (#2297) |
| 1385 |
- Remove spaces around power operators if both operands are simple (#2726) |
| 1386 |
- Work around bug that causes unstable formatting in some cases in the presence of the |
| 1387 |
magic trailing comma (#2807) |
| 1388 |
- Use parentheses for attribute access on decimal float and int literals (#2799) |
| 1389 |
- Don't add whitespace for attribute access on hexadecimal, binary, octal, and complex |
| 1390 |
literals (#2799) |
| 1391 |
- Treat blank lines in stubs the same inside top-level `if` statements (#2820) |
| 1392 |
- Fix unstable formatting with semicolons and arithmetic expressions (#2817) |
| 1393 |
- Fix unstable formatting around magic trailing comma (#2572) |
| 1394 |
|
| 1395 |
### Parser |
| 1396 |
|
| 1397 |
- Fix mapping cases that contain as-expressions, like `case {"key": 1 | 2 as password}` |
| 1398 |
(#2686) |
| 1399 |
- Fix cases that contain multiple top-level as-expressions, like `case 1 as a, 2 as b` |
| 1400 |
(#2716) |
| 1401 |
- Fix call patterns that contain as-expressions with keyword arguments, like |
| 1402 |
`case Foo(bar=baz as quux)` (#2749) |
| 1403 |
- Tuple unpacking on `return` and `yield` constructs now implies 3.8+ (#2700) |
| 1404 |
- Unparenthesized tuples on annotated assignments (e.g |
| 1405 |
`values: Tuple[int, ...] = 1, 2, 3`) now implies 3.8+ (#2708) |
| 1406 |
- Fix handling of standalone `match()` or `case()` when there is a trailing newline or a |
| 1407 |
comment inside of the parentheses. (#2760) |
| 1408 |
- `from __future__ import annotations` statement now implies Python 3.7+ (#2690) |
| 1409 |
|
| 1410 |
### Performance |
| 1411 |
|
| 1412 |
- Speed-up the new backtracking parser about 4X in general (enabled when |
| 1413 |
`--target-version` is set to 3.10 and higher). (#2728) |
| 1414 |
- _Black_ is now compiled with [mypyc](https://github.com/mypyc/mypyc) for an overall 2x |
| 1415 |
speed-up. 64-bit Windows, MacOS, and Linux (not including musl) are supported. (#1009, |
| 1416 |
#2431) |
| 1417 |
|
| 1418 |
### Configuration |
| 1419 |
|
| 1420 |
- Do not accept bare carriage return line endings in pyproject.toml (#2408) |
| 1421 |
- Add configuration option (`python-cell-magics`) to format cells with custom magics in |
| 1422 |
Jupyter Notebooks (#2744) |
| 1423 |
- Allow setting custom cache directory on all platforms with environment variable |
| 1424 |
`BLACK_CACHE_DIR` (#2739). |
| 1425 |
- Enable Python 3.10+ by default, without any extra need to specify |
| 1426 |
`--target-version=py310`. (#2758) |
| 1427 |
- Make passing `SRC` or `--code` mandatory and mutually exclusive (#2804) |
| 1428 |
|
| 1429 |
### Output |
| 1430 |
|
| 1431 |
- Improve error message for invalid regular expression (#2678) |
| 1432 |
- Improve error message when parsing fails during AST safety check by embedding the |
| 1433 |
underlying SyntaxError (#2693) |
| 1434 |
- No longer color diff headers white as it's unreadable in light themed terminals |
| 1435 |
(#2691) |
| 1436 |
- Text coloring added in the final statistics (#2712) |
| 1437 |
- Verbose mode also now describes how a project root was discovered and which paths will |
| 1438 |
be formatted. (#2526) |
| 1439 |
|
| 1440 |
### Packaging |
| 1441 |
|
| 1442 |
- All upper version bounds on dependencies have been removed (#2718) |
| 1443 |
- `typing-extensions` is no longer a required dependency in Python 3.10+ (#2772) |
| 1444 |
- Set `click` lower bound to `8.0.0` (#2791) |
| 1445 |
|
| 1446 |
### Integrations |
| 1447 |
|
| 1448 |
- Update GitHub action to support containerized runs (#2748) |
| 1449 |
|
| 1450 |
### Documentation |
| 1451 |
|
| 1452 |
- Change protocol in pip installation instructions to `https://` (#2761) |
| 1453 |
- Change HTML theme to Furo primarily for its responsive design and mobile support |
| 1454 |
(#2793) |
| 1455 |
- Deprecate the `black-primer` tool (#2809) |
| 1456 |
- Document Python support policy (#2819) |
| 1457 |
|
| 1458 |
## Version 21.12b0 |
| 1459 |
|
| 1460 |
### _Black_ |
| 1461 |
|
| 1462 |
- Fix determination of f-string expression spans (#2654) |
| 1463 |
- Fix bad formatting of error messages about EOF in multi-line statements (#2343) |
| 1464 |
- Functions and classes in blocks now have more consistent surrounding spacing (#2472) |
| 1465 |
|
| 1466 |
#### Jupyter Notebook support |
| 1467 |
|
| 1468 |
- Cell magics are now only processed if they are known Python cell magics. Earlier, all |
| 1469 |
cell magics were tokenized, leading to possible indentation errors e.g. with |
| 1470 |
`%%writefile`. (#2630) |
| 1471 |
- Fix assignment to environment variables in Jupyter Notebooks (#2642) |
| 1472 |
|
| 1473 |
#### Python 3.10 support |
| 1474 |
|
| 1475 |
- Point users to using `--target-version py310` if we detect 3.10-only syntax (#2668) |
| 1476 |
- Fix `match` statements with open sequence subjects, like `match a, b:` or |
| 1477 |
`match a, *b:` (#2639) (#2659) |
| 1478 |
- Fix `match`/`case` statements that contain `match`/`case` soft keywords multiple |
| 1479 |
times, like `match re.match()` (#2661) |
| 1480 |
- Fix `case` statements with an inline body (#2665) |
| 1481 |
- Fix styling of starred expressions inside `match` subject (#2667) |
| 1482 |
- Fix parser error location on invalid syntax in a `match` statement (#2649) |
| 1483 |
- Fix Python 3.10 support on platforms without ProcessPoolExecutor (#2631) |
| 1484 |
- Improve parsing performance on code that uses `match` under `--target-version py310` |
| 1485 |
up to ~50% (#2670) |
| 1486 |
|
| 1487 |
### Packaging |
| 1488 |
|
| 1489 |
- Remove dependency on `regex` (#2644) (#2663) |
| 1490 |
|
| 1491 |
## Version 21.11b1 |
| 1492 |
|
| 1493 |
### _Black_ |
| 1494 |
|
| 1495 |
- Bumped regex version minimum to 2021.4.4 to fix Pattern class usage (#2621) |
| 1496 |
|
| 1497 |
## Version 21.11b0 |
| 1498 |
|
| 1499 |
### _Black_ |
| 1500 |
|
| 1501 |
- Warn about Python 2 deprecation in more cases by improving Python 2 only syntax |
| 1502 |
detection (#2592) |
| 1503 |
- Add experimental PyPy support (#2559) |
| 1504 |
- Add partial support for the match statement. As it's experimental, it's only enabled |
| 1505 |
when `--target-version py310` is explicitly specified (#2586) |
| 1506 |
- Add support for parenthesized with (#2586) |
| 1507 |
- Declare support for Python 3.10 for running Black (#2562) |
| 1508 |
|
| 1509 |
### Integrations |
| 1510 |
|
| 1511 |
- Fixed vim plugin with Python 3.10 by removing deprecated distutils import (#2610) |
| 1512 |
- The vim plugin now parses `skip_magic_trailing_comma` from pyproject.toml (#2613) |
| 1513 |
|
| 1514 |
## Version 21.10b0 |
| 1515 |
|
| 1516 |
### _Black_ |
| 1517 |
|
| 1518 |
- Document stability policy, that will apply for non-beta releases (#2529) |
| 1519 |
- Add new `--workers` parameter (#2514) |
| 1520 |
- Fixed feature detection for positional-only arguments in lambdas (#2532) |
| 1521 |
- Bumped typed-ast version minimum to 1.4.3 for 3.10 compatibility (#2519) |
| 1522 |
- Fixed a Python 3.10 compatibility issue where the loop argument was still being passed |
| 1523 |
even though it has been removed (#2580) |
| 1524 |
- Deprecate Python 2 formatting support (#2523) |
| 1525 |
|
| 1526 |
### _Blackd_ |
| 1527 |
|
| 1528 |
- Remove dependency on aiohttp-cors (#2500) |
| 1529 |
- Bump required aiohttp version to 3.7.4 (#2509) |
| 1530 |
|
| 1531 |
### _Black-Primer_ |
| 1532 |
|
| 1533 |
- Add primer support for --projects (#2555) |
| 1534 |
- Print primer summary after individual failures (#2570) |
| 1535 |
|
| 1536 |
### Integrations |
| 1537 |
|
| 1538 |
- Allow to pass `target_version` in the vim plugin (#1319) |
| 1539 |
- Install build tools in docker file and use multi-stage build to keep the image size |
| 1540 |
down (#2582) |
| 1541 |
|
| 1542 |
## Version 21.9b0 |
| 1543 |
|
| 1544 |
### Packaging |
| 1545 |
|
| 1546 |
- Fix missing modules in self-contained binaries (#2466) |
| 1547 |
- Fix missing toml extra used during installation (#2475) |
| 1548 |
|
| 1549 |
## Version 21.8b0 |
| 1550 |
|
| 1551 |
### _Black_ |
| 1552 |
|
| 1553 |
- Add support for formatting Jupyter Notebook files (#2357) |
| 1554 |
- Move from `appdirs` dependency to `platformdirs` (#2375) |
| 1555 |
- Present a more user-friendly error if .gitignore is invalid (#2414) |
| 1556 |
- The failsafe for accidentally added backslashes in f-string expressions has been |
| 1557 |
hardened to handle more edge cases during quote normalization (#2437) |
| 1558 |
- Avoid changing a function return type annotation's type to a tuple by adding a |
| 1559 |
trailing comma (#2384) |
| 1560 |
- Parsing support has been added for unparenthesized walruses in set literals, set |
| 1561 |
comprehensions, and indices (#2447). |
| 1562 |
- Pin `setuptools-scm` build-time dependency version (#2457) |
| 1563 |
- Exclude typing-extensions version 3.10.0.1 due to it being broken on Python 3.10 |
| 1564 |
(#2460) |
| 1565 |
|
| 1566 |
### _Blackd_ |
| 1567 |
|
| 1568 |
- Replace sys.exit(-1) with raise ImportError as it plays more nicely with tools that |
| 1569 |
scan installed packages (#2440) |
| 1570 |
|
| 1571 |
### Integrations |
| 1572 |
|
| 1573 |
- The provided pre-commit hooks no longer specify `language_version` to avoid overriding |
| 1574 |
`default_language_version` (#2430) |
| 1575 |
|
| 1576 |
## Version 21.7b0 |
| 1577 |
|
| 1578 |
### _Black_ |
| 1579 |
|
| 1580 |
- Configuration files using TOML features higher than spec v0.5.0 are now supported |
| 1581 |
(#2301) |
| 1582 |
- Add primer support and test for code piped into black via STDIN (#2315) |
| 1583 |
- Fix internal error when `FORCE_OPTIONAL_PARENTHESES` feature is enabled (#2332) |
| 1584 |
- Accept empty stdin (#2346) |
| 1585 |
- Provide a more useful error when parsing fails during AST safety checks (#2304) |
| 1586 |
|
| 1587 |
### Docker |
| 1588 |
|
| 1589 |
- Add new `latest_release` tag automation to follow latest black release on docker |
| 1590 |
images (#2374) |
| 1591 |
|
| 1592 |
### Integrations |
| 1593 |
|
| 1594 |
- The vim plugin now searches upwards from the directory containing the current buffer |
| 1595 |
instead of the current working directory for pyproject.toml. (#1871) |
| 1596 |
- The vim plugin now reads the correct string normalization option in pyproject.toml |
| 1597 |
(#1869) |
| 1598 |
- The vim plugin no longer crashes Black when there's boolean values in pyproject.toml |
| 1599 |
(#1869) |
| 1600 |
|
| 1601 |
## Version 21.6b0 |
| 1602 |
|
| 1603 |
### _Black_ |
| 1604 |
|
| 1605 |
- Fix failure caused by `fmt: skip` and indentation (#2281) |
| 1606 |
- Account for += assignment when deciding whether to split string (#2312) |
| 1607 |
- Correct max string length calculation when there are string operators (#2292) |
| 1608 |
- Fixed option usage when using the `--code` flag (#2259) |
| 1609 |
- Do not call `uvloop.install()` when _Black_ is used as a library (#2303) |
| 1610 |
- Added `--required-version` option to require a specific version to be running (#2300) |
| 1611 |
- Fix incorrect custom breakpoint indices when string group contains fake f-strings |
| 1612 |
(#2311) |
| 1613 |
- Fix regression where `R` prefixes would be lowercased for docstrings (#2285) |
| 1614 |
- Fix handling of named escapes (`\N{...}`) when `--experimental-string-processing` is |
| 1615 |
used (#2319) |
| 1616 |
|
| 1617 |
### Integrations |
| 1618 |
|
| 1619 |
- The official Black action now supports choosing what version to use, and supports the |
| 1620 |
major 3 OSes. (#1940) |
| 1621 |
|
| 1622 |
## Version 21.5b2 |
| 1623 |
|
| 1624 |
### _Black_ |
| 1625 |
|
| 1626 |
- A space is no longer inserted into empty docstrings (#2249) |
| 1627 |
- Fix handling of .gitignore files containing non-ASCII characters on Windows (#2229) |
| 1628 |
- Respect `.gitignore` files in all levels, not only `root/.gitignore` file (apply |
| 1629 |
`.gitignore` rules like `git` does) (#2225) |
| 1630 |
- Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227) |
| 1631 |
- Add extra uvloop install + import support if in python env (#2258) |
| 1632 |
- Fix --experimental-string-processing crash when matching parens are not found (#2283) |
| 1633 |
- Make sure to split lines that start with a string operator (#2286) |
| 1634 |
- Fix regular expression that black uses to identify f-expressions (#2287) |
| 1635 |
|
| 1636 |
### _Blackd_ |
| 1637 |
|
| 1638 |
- Add a lower bound for the `aiohttp-cors` dependency. Only 0.4.0 or higher is |
| 1639 |
supported. (#2231) |
| 1640 |
|
| 1641 |
### Packaging |
| 1642 |
|
| 1643 |
- Release self-contained x86_64 MacOS binaries as part of the GitHub release pipeline |
| 1644 |
(#2198) |
| 1645 |
- Always build binaries with the latest available Python (#2260) |
| 1646 |
|
| 1647 |
### Documentation |
| 1648 |
|
| 1649 |
- Add discussion of magic comments to FAQ page (#2272) |
| 1650 |
- `--experimental-string-processing` will be enabled by default in the future (#2273) |
| 1651 |
- Fix typos discovered by codespell (#2228) |
| 1652 |
- Fix Vim plugin installation instructions. (#2235) |
| 1653 |
- Add new Frequently Asked Questions page (#2247) |
| 1654 |
- Fix encoding + symlink issues preventing proper build on Windows (#2262) |
| 1655 |
|
| 1656 |
## Version 21.5b1 |
| 1657 |
|
| 1658 |
### _Black_ |
| 1659 |
|
| 1660 |
- Refactor `src/black/__init__.py` into many files (#2206) |
| 1661 |
|
| 1662 |
### Documentation |
| 1663 |
|
| 1664 |
- Replaced all remaining references to the |
| 1665 |
[`master`](https://github.com/psf/black/tree/main) branch with the |
| 1666 |
[`main`](https://github.com/psf/black/tree/main) branch. Some additional changes in |
| 1667 |
the source code were also made. (#2210) |
| 1668 |
- Significantly reorganized the documentation to make much more sense. Check them out by |
| 1669 |
heading over to [the stable docs on RTD](https://black.readthedocs.io/en/stable/). |
| 1670 |
(#2174) |
| 1671 |
|
| 1672 |
## Version 21.5b0 |
| 1673 |
|
| 1674 |
### _Black_ |
| 1675 |
|
| 1676 |
- Set `--pyi` mode if `--stdin-filename` ends in `.pyi` (#2169) |
| 1677 |
- Stop detecting target version as Python 3.9+ with pre-PEP-614 decorators that are |
| 1678 |
being called but with no arguments (#2182) |
| 1679 |
|
| 1680 |
### _Black-Primer_ |
| 1681 |
|
| 1682 |
- Add `--no-diff` to black-primer to suppress formatting changes (#2187) |
| 1683 |
|
| 1684 |
## Version 21.4b2 |
| 1685 |
|
| 1686 |
### _Black_ |
| 1687 |
|
| 1688 |
- Fix crash if the user configuration directory is inaccessible. (#2158) |
| 1689 |
|
| 1690 |
- Clarify |
| 1691 |
[circumstances](https://github.com/psf/black/blob/master/docs/the_black_code_style.md#pragmatism) |
| 1692 |
in which _Black_ may change the AST (#2159) |
| 1693 |
|
| 1694 |
- Allow `.gitignore` rules to be overridden by specifying `exclude` in `pyproject.toml` |
| 1695 |
or on the command line. (#2170) |
| 1696 |
|
| 1697 |
### _Packaging_ |
| 1698 |
|
| 1699 |
- Install `primer.json` (used by `black-primer` by default) with black. (#2154) |
| 1700 |
|
| 1701 |
## Version 21.4b1 |
| 1702 |
|
| 1703 |
### _Black_ |
| 1704 |
|
| 1705 |
- Fix crash on docstrings ending with "\\ ". (#2142) |
| 1706 |
|
| 1707 |
- Fix crash when atypical whitespace is cleaned out of dostrings (#2120) |
| 1708 |
|
| 1709 |
- Reflect the `--skip-magic-trailing-comma` and `--experimental-string-processing` flags |
| 1710 |
in the name of the cache file. Without this fix, changes in these flags would not take |
| 1711 |
effect if the cache had already been populated. (#2131) |
| 1712 |
|
| 1713 |
- Don't remove necessary parentheses from assignment expression containing assert / |
| 1714 |
return statements. (#2143) |
| 1715 |
|
| 1716 |
### _Packaging_ |
| 1717 |
|
| 1718 |
- Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling |
| 1719 |
|
| 1720 |
## Version 21.4b0 |
| 1721 |
|
| 1722 |
### _Black_ |
| 1723 |
|
| 1724 |
- Fixed a rare but annoying formatting instability created by the combination of |
| 1725 |
optional trailing commas inserted by `Black` and optional parentheses looking at |
| 1726 |
pre-existing "magic" trailing commas. This fixes issue #1629 and all of its many many |
| 1727 |
duplicates. (#2126) |
| 1728 |
|
| 1729 |
- `Black` now processes one-line docstrings by stripping leading and trailing spaces, |
| 1730 |
and adding a padding space when needed to break up """". (#1740) |
| 1731 |
|
| 1732 |
- `Black` now cleans up leading non-breaking spaces in comments (#2092) |
| 1733 |
|
| 1734 |
- `Black` now respects `--skip-string-normalization` when normalizing multiline |
| 1735 |
docstring quotes (#1637) |
| 1736 |
|
| 1737 |
- `Black` no longer removes all empty lines between non-function code and decorators |
| 1738 |
when formatting typing stubs. Now `Black` enforces a single empty line. (#1646) |
| 1739 |
|
| 1740 |
- `Black` no longer adds an incorrect space after a parenthesized assignment expression |
| 1741 |
in if/while statements (#1655) |
| 1742 |
|
| 1743 |
- Added `--skip-magic-trailing-comma` / `-C` to avoid using trailing commas as a reason |
| 1744 |
to split lines (#1824) |
| 1745 |
|
| 1746 |
- fixed a crash when PWD=/ on POSIX (#1631) |
| 1747 |
|
| 1748 |
- fixed "I/O operation on closed file" when using --diff (#1664) |
| 1749 |
|
| 1750 |
- Prevent coloured diff output being interleaved with multiple files (#1673) |
| 1751 |
|
| 1752 |
- Added support for PEP 614 relaxed decorator syntax on python 3.9 (#1711) |
| 1753 |
|
| 1754 |
- Added parsing support for unparenthesized tuples and yield expressions in annotated |
| 1755 |
assignments (#1835) |
| 1756 |
|
| 1757 |
- added `--extend-exclude` argument (PR #2005) |
| 1758 |
|
| 1759 |
- speed up caching by avoiding pathlib (#1950) |
| 1760 |
|
| 1761 |
- `--diff` correctly indicates when a file doesn't end in a newline (#1662) |
| 1762 |
|
| 1763 |
- Added `--stdin-filename` argument to allow stdin to respect `--force-exclude` rules |
| 1764 |
(#1780) |
| 1765 |
|
| 1766 |
- Lines ending with `fmt: skip` will now be not formatted (#1800) |
| 1767 |
|
| 1768 |
- PR #2053: Black no longer relies on typed-ast for Python 3.8 and higher |
| 1769 |
|
| 1770 |
- PR #2053: Python 2 support is now optional, install with |
| 1771 |
`python3 -m pip install black[python2]` to maintain support. |
| 1772 |
|
| 1773 |
- Exclude `venv` directory by default (#1683) |
| 1774 |
|
| 1775 |
- Fixed "Black produced code that is not equivalent to the source" when formatting |
| 1776 |
Python 2 docstrings (#2037) |
| 1777 |
|
| 1778 |
### _Packaging_ |
| 1779 |
|
| 1780 |
- Self-contained native _Black_ binaries are now provided for releases via GitHub |
| 1781 |
Releases (#1743) |
| 1782 |
|
| 1783 |
## Version 20.8b1 |
| 1784 |
|
| 1785 |
### _Packaging_ |
| 1786 |
|
| 1787 |
- explicitly depend on Click 7.1.2 or newer as `Black` no longer works with versions |
| 1788 |
older than 7.0 |
| 1789 |
|
| 1790 |
## Version 20.8b0 |
| 1791 |
|
| 1792 |
### _Black_ |
| 1793 |
|
| 1794 |
- re-implemented support for explicit trailing commas: now it works consistently within |
| 1795 |
any bracket pair, including nested structures (#1288 and duplicates) |
| 1796 |
|
| 1797 |
- `Black` now reindents docstrings when reindenting code around it (#1053) |
| 1798 |
|
| 1799 |
- `Black` now shows colored diffs (#1266) |
| 1800 |
|
| 1801 |
- `Black` is now packaged using 'py3' tagged wheels (#1388) |
| 1802 |
|
| 1803 |
- `Black` now supports Python 3.8 code, e.g. star expressions in return statements |
| 1804 |
(#1121) |
| 1805 |
|
| 1806 |
- `Black` no longer normalizes capital R-string prefixes as those have a |
| 1807 |
community-accepted meaning (#1244) |
| 1808 |
|
| 1809 |
- `Black` now uses exit code 2 when specified configuration file doesn't exit (#1361) |
| 1810 |
|
| 1811 |
- `Black` now works on AWS Lambda (#1141) |
| 1812 |
|
| 1813 |
- added `--force-exclude` argument (#1032) |
| 1814 |
|
| 1815 |
- removed deprecated `--py36` option (#1236) |
| 1816 |
|
| 1817 |
- fixed `--diff` output when EOF is encountered (#526) |
| 1818 |
|
| 1819 |
- fixed `# fmt: off` handling around decorators (#560) |
| 1820 |
|
| 1821 |
- fixed unstable formatting with some `# type: ignore` comments (#1113) |
| 1822 |
|
| 1823 |
- fixed invalid removal on organizing brackets followed by indexing (#1575) |
| 1824 |
|
| 1825 |
- introduced `black-primer`, a CI tool that allows us to run regression tests against |
| 1826 |
existing open source users of Black (#1402) |
| 1827 |
|
| 1828 |
- introduced property-based fuzzing to our test suite based on Hypothesis and |
| 1829 |
Hypothersmith (#1566) |
| 1830 |
|
| 1831 |
- implemented experimental and disabled by default long string rewrapping (#1132), |
| 1832 |
hidden under a `--experimental-string-processing` flag while it's being worked on; |
| 1833 |
this is an undocumented and unsupported feature, you lose Internet points for |
| 1834 |
depending on it (#1609) |
| 1835 |
|
| 1836 |
### Vim plugin |
| 1837 |
|
| 1838 |
- prefer virtualenv packages over global packages (#1383) |
| 1839 |
|
| 1840 |
## Version 19.10b0 |
| 1841 |
|
| 1842 |
- added support for PEP 572 assignment expressions (#711) |
| 1843 |
|
| 1844 |
- added support for PEP 570 positional-only arguments (#943) |
| 1845 |
|
| 1846 |
- added support for async generators (#593) |
| 1847 |
|
| 1848 |
- added support for pre-splitting collections by putting an explicit trailing comma |
| 1849 |
inside (#826) |
| 1850 |
|
| 1851 |
- added `black -c` as a way to format code passed from the command line (#761) |
| 1852 |
|
| 1853 |
- --safe now works with Python 2 code (#840) |
| 1854 |
|
| 1855 |
- fixed grammar selection for Python 2-specific code (#765) |
| 1856 |
|
| 1857 |
- fixed feature detection for trailing commas in function definitions and call sites |
| 1858 |
(#763) |
| 1859 |
|
| 1860 |
- `# fmt: off`/`# fmt: on` comment pairs placed multiple times within the same block of |
| 1861 |
code now behave correctly (#1005) |
| 1862 |
|
| 1863 |
- _Black_ no longer crashes on Windows machines with more than 61 cores (#838) |
| 1864 |
|
| 1865 |
- _Black_ no longer crashes on standalone comments prepended with a backslash (#767) |
| 1866 |
|
| 1867 |
- _Black_ no longer crashes on `from` ... `import` blocks with comments (#829) |
| 1868 |
|
| 1869 |
- _Black_ no longer crashes on Python 3.7 on some platform configurations (#494) |
| 1870 |
|
| 1871 |
- _Black_ no longer fails on comments in from-imports (#671) |
| 1872 |
|
| 1873 |
- _Black_ no longer fails when the file starts with a backslash (#922) |
| 1874 |
|
| 1875 |
- _Black_ no longer merges regular comments with type comments (#1027) |
| 1876 |
|
| 1877 |
- _Black_ no longer splits long lines that contain type comments (#997) |
| 1878 |
|
| 1879 |
- removed unnecessary parentheses around `yield` expressions (#834) |
| 1880 |
|
| 1881 |
- added parentheses around long tuples in unpacking assignments (#832) |
| 1882 |
|
| 1883 |
- added parentheses around complex powers when they are prefixed by a unary operator |
| 1884 |
(#646) |
| 1885 |
|
| 1886 |
- fixed bug that led _Black_ format some code with a line length target of 1 (#762) |
| 1887 |
|
| 1888 |
- _Black_ no longer introduces quotes in f-string subexpressions on string boundaries |
| 1889 |
(#863) |
| 1890 |
|
| 1891 |
- if _Black_ puts parenthesis around a single expression, it moves comments to the |
| 1892 |
wrapped expression instead of after the brackets (#872) |
| 1893 |
|
| 1894 |
- `blackd` now returns the version of _Black_ in the response headers (#1013) |
| 1895 |
|
| 1896 |
- `blackd` can now output the diff of formats on source code when the `X-Diff` header is |
| 1897 |
provided (#969) |
| 1898 |
|
| 1899 |
## Version 19.3b0 |
| 1900 |
|
| 1901 |
- new option `--target-version` to control which Python versions _Black_-formatted code |
| 1902 |
should target (#618) |
| 1903 |
|
| 1904 |
- deprecated `--py36` (use `--target-version=py36` instead) (#724) |
| 1905 |
|
| 1906 |
- _Black_ no longer normalizes numeric literals to include `_` separators (#696) |
| 1907 |
|
| 1908 |
- long `del` statements are now split into multiple lines (#698) |
| 1909 |
|
| 1910 |
- type comments are no longer mangled in function signatures |
| 1911 |
|
| 1912 |
- improved performance of formatting deeply nested data structures (#509) |
| 1913 |
|
| 1914 |
- _Black_ now properly formats multiple files in parallel on Windows (#632) |
| 1915 |
|
| 1916 |
- _Black_ now creates cache files atomically which allows it to be used in parallel |
| 1917 |
pipelines (like `xargs -P8`) (#673) |
| 1918 |
|
| 1919 |
- _Black_ now correctly indents comments in files that were previously formatted with |
| 1920 |
tabs (#262) |
| 1921 |
|
| 1922 |
- `blackd` now supports CORS (#622) |
| 1923 |
|
| 1924 |
## Version 18.9b0 |
| 1925 |
|
| 1926 |
- numeric literals are now formatted by _Black_ (#452, #461, #464, #469): |
| 1927 |
- numeric literals are normalized to include `_` separators on Python 3.6+ code |
| 1928 |
|
| 1929 |
- added `--skip-numeric-underscore-normalization` to disable the above behavior and |
| 1930 |
leave numeric underscores as they were in the input |
| 1931 |
|
| 1932 |
- code with `_` in numeric literals is recognized as Python 3.6+ |
| 1933 |
|
| 1934 |
- most letters in numeric literals are lowercased (e.g., in `1e10`, `0x01`) |
| 1935 |
|
| 1936 |
- hexadecimal digits are always uppercased (e.g. `0xBADC0DE`) |
| 1937 |
|
| 1938 |
- added `blackd`, see |
| 1939 |
[its documentation](https://github.com/psf/black/blob/18.9b0/README.md#blackd) for |
| 1940 |
more info (#349) |
| 1941 |
|
| 1942 |
- adjacent string literals are now correctly split into multiple lines (#463) |
| 1943 |
|
| 1944 |
- trailing comma is now added to single imports that don't fit on a line (#250) |
| 1945 |
|
| 1946 |
- cache is now populated when `--check` is successful for a file which speeds up |
| 1947 |
consecutive checks of properly formatted unmodified files (#448) |
| 1948 |
|
| 1949 |
- whitespace at the beginning of the file is now removed (#399) |
| 1950 |
|
| 1951 |
- fixed mangling [pweave](http://mpastell.com/pweave/) and |
| 1952 |
[Spyder IDE](https://www.spyder-ide.org/) special comments (#532) |
| 1953 |
|
| 1954 |
- fixed unstable formatting when unpacking big tuples (#267) |
| 1955 |
|
| 1956 |
- fixed parsing of `__future__` imports with renames (#389) |
| 1957 |
|
| 1958 |
- fixed scope of `# fmt: off` when directly preceding `yield` and other nodes (#385) |
| 1959 |
|
| 1960 |
- fixed formatting of lambda expressions with default arguments (#468) |
| 1961 |
|
| 1962 |
- fixed `async for` statements: _Black_ no longer breaks them into separate lines (#372) |
| 1963 |
|
| 1964 |
- note: the Vim plugin stopped registering `,=` as a default chord as it turned out to |
| 1965 |
be a bad idea (#415) |
| 1966 |
|
| 1967 |
## Version 18.6b4 |
| 1968 |
|
| 1969 |
- hotfix: don't freeze when multiple comments directly precede `# fmt: off` (#371) |
| 1970 |
|
| 1971 |
## Version 18.6b3 |
| 1972 |
|
| 1973 |
- typing stub files (`.pyi`) now have blank lines added after constants (#340) |
| 1974 |
|
| 1975 |
- `# fmt: off` and `# fmt: on` are now much more dependable: |
| 1976 |
- they now work also within bracket pairs (#329) |
| 1977 |
|
| 1978 |
- they now correctly work across function/class boundaries (#335) |
| 1979 |
|
| 1980 |
- they now work when an indentation block starts with empty lines or misaligned |
| 1981 |
comments (#334) |
| 1982 |
|
| 1983 |
- made Click not fail on invalid environments; note that Click is right but the |
| 1984 |
likelihood we'll need to access non-ASCII file paths when dealing with Python source |
| 1985 |
code is low (#277) |
| 1986 |
|
| 1987 |
- fixed improper formatting of f-strings with quotes inside interpolated expressions |
| 1988 |
(#322) |
| 1989 |
|
| 1990 |
- fixed unnecessary slowdown when long list literals where found in a file |
| 1991 |
|
| 1992 |
- fixed unnecessary slowdown on AST nodes with very many siblings |
| 1993 |
|
| 1994 |
- fixed cannibalizing backslashes during string normalization |
| 1995 |
|
| 1996 |
- fixed a crash due to symbolic links pointing outside of the project directory (#338) |
| 1997 |
|
| 1998 |
## Version 18.6b2 |
| 1999 |
|
| 2000 |
- added `--config` (#65) |
| 2001 |
|
| 2002 |
- added `-h` equivalent to `--help` (#316) |
| 2003 |
|
| 2004 |
- fixed improper unmodified file caching when `-S` was used |
| 2005 |
|
| 2006 |
- fixed extra space in string unpacking (#305) |
| 2007 |
|
| 2008 |
- fixed formatting of empty triple quoted strings (#313) |
| 2009 |
|
| 2010 |
- fixed unnecessary slowdown in comment placement calculation on lines without comments |
| 2011 |
|
| 2012 |
## Version 18.6b1 |
| 2013 |
|
| 2014 |
- hotfix: don't output human-facing information on stdout (#299) |
| 2015 |
|
| 2016 |
- hotfix: don't output cake emoji on non-zero return code (#300) |
| 2017 |
|
| 2018 |
## Version 18.6b0 |
| 2019 |
|
| 2020 |
- added `--include` and `--exclude` (#270) |
| 2021 |
|
| 2022 |
- added `--skip-string-normalization` (#118) |
| 2023 |
|
| 2024 |
- added `--verbose` (#283) |
| 2025 |
|
| 2026 |
- the header output in `--diff` now actually conforms to the unified diff spec |
| 2027 |
|
| 2028 |
- fixed long trivial assignments being wrapped in unnecessary parentheses (#273) |
| 2029 |
|
| 2030 |
- fixed unnecessary parentheses when a line contained multiline strings (#232) |
| 2031 |
|
| 2032 |
- fixed stdin handling not working correctly if an old version of Click was used (#276) |
| 2033 |
|
| 2034 |
- _Black_ now preserves line endings when formatting a file in place (#258) |
| 2035 |
|
| 2036 |
## Version 18.5b1 |
| 2037 |
|
| 2038 |
- added `--pyi` (#249) |
| 2039 |
|
| 2040 |
- added `--py36` (#249) |
| 2041 |
|
| 2042 |
- Python grammar pickle caches are stored with the formatting caches, making _Black_ |
| 2043 |
work in environments where site-packages is not user-writable (#192) |
| 2044 |
|
| 2045 |
- _Black_ now enforces a PEP 257 empty line after a class-level docstring (and/or |
| 2046 |
fields) and the first method |
| 2047 |
|
| 2048 |
- fixed invalid code produced when standalone comments were present in a trailer that |
| 2049 |
was omitted from line splitting on a large expression (#237) |
| 2050 |
|
| 2051 |
- fixed optional parentheses being removed within `# fmt: off` sections (#224) |
| 2052 |
|
| 2053 |
- fixed invalid code produced when stars in very long imports were incorrectly wrapped |
| 2054 |
in optional parentheses (#234) |
| 2055 |
|
| 2056 |
- fixed unstable formatting when inline comments were moved around in a trailer that was |
| 2057 |
omitted from line splitting on a large expression (#238) |
| 2058 |
|
| 2059 |
- fixed extra empty line between a class declaration and the first method if no class |
| 2060 |
docstring or fields are present (#219) |
| 2061 |
|
| 2062 |
- fixed extra empty line between a function signature and an inner function or inner |
| 2063 |
class (#196) |
| 2064 |
|
| 2065 |
## Version 18.5b0 |
| 2066 |
|
| 2067 |
- call chains are now formatted according to the |
| 2068 |
[fluent interfaces](https://en.wikipedia.org/wiki/Fluent_interface) style (#67) |
| 2069 |
|
| 2070 |
- data structure literals (tuples, lists, dictionaries, and sets) are now also always |
| 2071 |
exploded like imports when they don't fit in a single line (#152) |
| 2072 |
|
| 2073 |
- slices are now formatted according to PEP 8 (#178) |
| 2074 |
|
| 2075 |
- parentheses are now also managed automatically on the right-hand side of assignments |
| 2076 |
and return statements (#140) |
| 2077 |
|
| 2078 |
- math operators now use their respective priorities for delimiting multiline |
| 2079 |
expressions (#148) |
| 2080 |
|
| 2081 |
- optional parentheses are now omitted on expressions that start or end with a bracket |
| 2082 |
and only contain a single operator (#177) |
| 2083 |
|
| 2084 |
- empty parentheses in a class definition are now removed (#145, #180) |
| 2085 |
|
| 2086 |
- string prefixes are now standardized to lowercase and `u` is removed on Python 3.6+ |
| 2087 |
only code and Python 2.7+ code with the `unicode_literals` future import (#188, #198, |
| 2088 |
#199) |
| 2089 |
|
| 2090 |
- typing stub files (`.pyi`) are now formatted in a style that is consistent with PEP |
| 2091 |
484 (#207, #210) |
| 2092 |
|
| 2093 |
- progress when reformatting many files is now reported incrementally |
| 2094 |
|
| 2095 |
- fixed trailers (content with brackets) being unnecessarily exploded into their own |
| 2096 |
lines after a dedented closing bracket (#119) |
| 2097 |
|
| 2098 |
- fixed an invalid trailing comma sometimes left in imports (#185) |
| 2099 |
|
| 2100 |
- fixed non-deterministic formatting when multiple pairs of removable parentheses were |
| 2101 |
used (#183) |
| 2102 |
|
| 2103 |
- fixed multiline strings being unnecessarily wrapped in optional parentheses in long |
| 2104 |
assignments (#215) |
| 2105 |
|
| 2106 |
- fixed not splitting long from-imports with only a single name |
| 2107 |
|
| 2108 |
- fixed Python 3.6+ file discovery by also looking at function calls with unpacking. |
| 2109 |
This fixed non-deterministic formatting if trailing commas where used both in function |
| 2110 |
signatures with stars and function calls with stars but the former would be |
| 2111 |
reformatted to a single line. |
| 2112 |
|
| 2113 |
- fixed crash on dealing with optional parentheses (#193) |
| 2114 |
|
| 2115 |
- fixed "is", "is not", "in", and "not in" not considered operators for splitting |
| 2116 |
purposes |
| 2117 |
|
| 2118 |
- fixed crash when dead symlinks where encountered |
| 2119 |
|
| 2120 |
## Version 18.4a4 |
| 2121 |
|
| 2122 |
- don't populate the cache on `--check` (#175) |
| 2123 |
|
| 2124 |
## Version 18.4a3 |
| 2125 |
|
| 2126 |
- added a "cache"; files already reformatted that haven't changed on disk won't be |
| 2127 |
reformatted again (#109) |
| 2128 |
|
| 2129 |
- `--check` and `--diff` are no longer mutually exclusive (#149) |
| 2130 |
|
| 2131 |
- generalized star expression handling, including double stars; this fixes |
| 2132 |
multiplication making expressions "unsafe" for trailing commas (#132) |
| 2133 |
|
| 2134 |
- _Black_ no longer enforces putting empty lines behind control flow statements (#90) |
| 2135 |
|
| 2136 |
- _Black_ now splits imports like "Mode 3 + trailing comma" of isort (#127) |
| 2137 |
|
| 2138 |
- fixed comment indentation when a standalone comment closes a block (#16, #32) |
| 2139 |
|
| 2140 |
- fixed standalone comments receiving extra empty lines if immediately preceding a |
| 2141 |
class, def, or decorator (#56, #154) |
| 2142 |
|
| 2143 |
- fixed `--diff` not showing entire path (#130) |
| 2144 |
|
| 2145 |
- fixed parsing of complex expressions after star and double stars in function calls |
| 2146 |
(#2) |
| 2147 |
|
| 2148 |
- fixed invalid splitting on comma in lambda arguments (#133) |
| 2149 |
|
| 2150 |
- fixed missing splits of ternary expressions (#141) |
| 2151 |
|
| 2152 |
## Version 18.4a2 |
| 2153 |
|
| 2154 |
- fixed parsing of unaligned standalone comments (#99, #112) |
| 2155 |
|
| 2156 |
- fixed placement of dictionary unpacking inside dictionary literals (#111) |
| 2157 |
|
| 2158 |
- Vim plugin now works on Windows, too |
| 2159 |
|
| 2160 |
- fixed unstable formatting when encountering unnecessarily escaped quotes in a string |
| 2161 |
(#120) |
| 2162 |
|
| 2163 |
## Version 18.4a1 |
| 2164 |
|
| 2165 |
- added `--quiet` (#78) |
| 2166 |
|
| 2167 |
- added automatic parentheses management (#4) |
| 2168 |
|
| 2169 |
- added [pre-commit](https://pre-commit.com) integration (#103, #104) |
| 2170 |
|
| 2171 |
- fixed reporting on `--check` with multiple files (#101, #102) |
| 2172 |
|
| 2173 |
- fixed removing backslash escapes from raw strings (#100, #105) |
| 2174 |
|
| 2175 |
## Version 18.4a0 |
| 2176 |
|
| 2177 |
- added `--diff` (#87) |
| 2178 |
|
| 2179 |
- add line breaks before all delimiters, except in cases like commas, to better comply |
| 2180 |
with PEP 8 (#73) |
| 2181 |
|
| 2182 |
- standardize string literals to use double quotes (almost) everywhere (#75) |
| 2183 |
|
| 2184 |
- fixed handling of standalone comments within nested bracketed expressions; _Black_ |
| 2185 |
will no longer produce super long lines or put all standalone comments at the end of |
| 2186 |
the expression (#22) |
| 2187 |
|
| 2188 |
- fixed 18.3a4 regression: don't crash and burn on empty lines with trailing whitespace |
| 2189 |
(#80) |
| 2190 |
|
| 2191 |
- fixed 18.3a4 regression: `# yapf: disable` usage as trailing comment would cause |
| 2192 |
_Black_ to not emit the rest of the file (#95) |
| 2193 |
|
| 2194 |
- when CTRL+C is pressed while formatting many files, _Black_ no longer freaks out with |
| 2195 |
a flurry of asyncio-related exceptions |
| 2196 |
|
| 2197 |
- only allow up to two empty lines on module level and only single empty lines within |
| 2198 |
functions (#74) |
| 2199 |
|
| 2200 |
## Version 18.3a4 |
| 2201 |
|
| 2202 |
- `# fmt: off` and `# fmt: on` are implemented (#5) |
| 2203 |
|
| 2204 |
- automatic detection of deprecated Python 2 forms of print statements and exec |
| 2205 |
statements in the formatted file (#49) |
| 2206 |
|
| 2207 |
- use proper spaces for complex expressions in default values of typed function |
| 2208 |
arguments (#60) |
| 2209 |
|
| 2210 |
- only return exit code 1 when --check is used (#50) |
| 2211 |
|
| 2212 |
- don't remove single trailing commas from square bracket indexing (#59) |
| 2213 |
|
| 2214 |
- don't omit whitespace if the previous factor leaf wasn't a math operator (#55) |
| 2215 |
|
| 2216 |
- omit extra space in kwarg unpacking if it's the first argument (#46) |
| 2217 |
|
| 2218 |
- omit extra space in |
| 2219 |
[Sphinx auto-attribute comments](http://www.sphinx-doc.org/en/stable/ext/autodoc.html#directive-autoattribute) |
| 2220 |
(#68) |
| 2221 |
|
| 2222 |
## Version 18.3a3 |
| 2223 |
|
| 2224 |
- don't remove single empty lines outside of bracketed expressions (#19) |
| 2225 |
|
| 2226 |
- added ability to pipe formatting from stdin to stdin (#25) |
| 2227 |
|
| 2228 |
- restored ability to format code with legacy usage of `async` as a name (#20, #42) |
| 2229 |
|
| 2230 |
- even better handling of numpy-style array indexing (#33, again) |
| 2231 |
|
| 2232 |
## Version 18.3a2 |
| 2233 |
|
| 2234 |
- changed positioning of binary operators to occur at beginning of lines instead of at |
| 2235 |
the end, following |
| 2236 |
[a recent change to PEP 8](https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b) |
| 2237 |
(#21) |
| 2238 |
|
| 2239 |
- ignore empty bracket pairs while splitting. This avoids very weirdly looking |
| 2240 |
formattings (#34, #35) |
| 2241 |
|
| 2242 |
- remove a trailing comma if there is a single argument to a call |
| 2243 |
|
| 2244 |
- if top level functions were separated by a comment, don't put four empty lines after |
| 2245 |
the upper function |
| 2246 |
|
| 2247 |
- fixed unstable formatting of newlines with imports |
| 2248 |
|
| 2249 |
- fixed unintentional folding of post scriptum standalone comments into last statement |
| 2250 |
if it was a simple statement (#18, #28) |
| 2251 |
|
| 2252 |
- fixed missing space in numpy-style array indexing (#33) |
| 2253 |
|
| 2254 |
- fixed spurious space after star-based unary expressions (#31) |
| 2255 |
|
| 2256 |
## Version 18.3a1 |
| 2257 |
|
| 2258 |
- added `--check` |
| 2259 |
|
| 2260 |
- only put trailing commas in function signatures and calls if it's safe to do so. If |
| 2261 |
the file is Python 3.6+ it's always safe, otherwise only safe if there are no `*args` |
| 2262 |
or `**kwargs` used in the signature or call. (#8) |
| 2263 |
|
| 2264 |
- fixed invalid spacing of dots in relative imports (#6, #13) |
| 2265 |
|
| 2266 |
- fixed invalid splitting after comma on unpacked variables in for-loops (#23) |
| 2267 |
|
| 2268 |
- fixed spurious space in parenthesized set expressions (#7) |
| 2269 |
|
| 2270 |
- fixed spurious space after opening parentheses and in default arguments (#14, #17) |
| 2271 |
|
| 2272 |
- fixed spurious space after unary operators when the operand was a complex expression |
| 2273 |
(#15) |
| 2274 |
|
| 2275 |
## Version 18.3a0 |
| 2276 |
|
| 2277 |
- first published version, Happy 🍰 Day 2018! |
| 2278 |
|
| 2279 |
- alpha quality |
| 2280 |
|
| 2281 |
- date-versioned (see: <https://calver.org/>) |