The uncompromising Python code formatter
--line-ranges
command-line option
(#4020)await (a ** b)
(#3994)case
blocks were not split into multiple lines. Also enable
general trailing comma rules on case
blocks (#4024)--include
(#3976)summary
parameter. (#3958)BLACK_CACHE_DIR
is set (#3937)type
were not acccepted inside match
statements
(#3950)Due to various issues, the previous release (23.9.0) did not include compiled mypyc wheels, which make Black significantly faster. These issues have now been fixed, and this release should come with compiled wheels once again.
There will be no wheels for Python 3.12 due to a bug in mypyc. We will provide 3.12 wheels in a future release as soon as the mypyc bug is fixed.
if sys.version_info > (3, x):
) and a function definition on the same level (#3862)IPython
if notebook cells do not contain magics (#3782)blackd
with single character input (#3558)https://github.com/psf/black
to https://github.com/psf/black-pre-commit-mirror
in
your .pre-commit-config.yaml
will make Black about 2x faster (#3828).black.env
folder specified by ENV_PATH
will now be removed on the completion
of the GitHub Action (#3759)type: ignore
within parentheses
(#3740)--workers
argument to Black can now be specified via the BLACK_NUM_WORKERS
environment variable (#3743).pytest_cache
, .ruff_cache
and .vscode
are now excluded by default (#3691)pyproject.toml
settings when running --stdin-filename
and the pyproject.toml
found isn't in the current working directory (#3719)exclude
and extend-exclude
have invalid data types in
pyproject.toml
, instead of silently doing the wrong thing (#3764)LANG=C
(#3768)IPython
in a case where we wouldn't need it (#3748)blackd
argument parser now shows the default values for options in their help
text (#3712)PYTHONWARNDEFAULTENCODING = 1
(#3763)This release fixes a longstanding confusing behavior in Black's GitHub action, where the version of the action did not determine the version of Black being run (issue #3382). In addition, there is a small bug fix around imports and a number of improvements to the preview style.
Please try out the
preview style
with black --preview
and tell us your feedback. All changes in the preview style are
expected to become part of Black's stable style in January 2024.
# fmt: skip
and # fmt: off
no longer have an extra blank line
added when they are right after another import line (#3610)async def
, async for
, and async with
statements are now formatted consistently
compared to their non-async version. (#3609)with
statements that contain two context managers will be consistently wrapped in
parentheses (#3589)、
U+3001
IDEOGRAPHIC COMMA, 。
U+3002 IDEOGRAPHIC FULL STOP, & ,
U+FF0C FULLWIDTH COMMA)
besides before spaces (#3445)...
(#3564)This is the first release of 2023, and following our stability policy, it comes with a number of improvements to our stable style, notably improvements to empty line handling and the removal of redundant parentheses in several contexts.
There are also many changes to the preview style; try out black --preview
and give us feedback to help us set the stable style for next year.
In addition to style changes, Black now automatically infers the supported Python versions from your pyproject.toml
file, removing the need to set Black's target versions separately.
--skip-string-normalization
/ -S
now prevents docstring prefixes from being normalized as expected (#3168) (since 22.8.0)--skip-magic-trailing-comma
or -C
, trailing commas are stripped from subscript expressions with more than 1 element (#3209) (22.8.0)with
statements (#2926) (22.6.0)#%%
are now standardised to # %%
(#2919) (22.3.0)except
statements (#2939) (22.3.0)for
loops (#2945) (22.3.0)# fmt: off
and # fmt: on
(#3439)if
-else
expressions (#2278)# fmt: skip
applied or there is a standalone comment between decorators (#3470)with
statements or tuples (#3473)await (yield)
when Black is compiled with mypyc (#3533)--target-version
from the project metadata specified in pyproject.toml
(#3219)0.971
to 0.991
so mypycified Black can be built on armv7 (#3380)
tomli
requirement on 3.11 alpha releases, working around a bug that would cause the requirement not to be installed on any non-final Python releases (#3448)packaging
version 22.0
or later. This is required for new functionality that needs to parse part of the project metadata (#3219)black --help
multiple times will return the same help contents each time (#3516)pyproject.toml
configuration variables (#3392)latest_prerelease
tag automation to follow latest black alpha release on docker images (#3465)vim-plug
installation instructions to offer more explicit options (#3468)This release provides a preview of Black's 2023 stable style. Black's default formatting style includes the following changes:
--skip-string-normalization
/ -S
now prevents docstring prefixes from being
normalized as expected (#3168) (since 22.8.0)--skip-magic-trailing-comma
or -C
, trailing commas are stripped from
subscript expressions with more than 1 element (#3209) (22.8.0)with
statements (#2926) (22.6.0)#%%
are now standardised to # %%
(#2919) (22.3.0)except
statements (#2939) (22.3.0)for
loops (#2945) (22.3.0)Please try it out and give feedback here: https://github.com/psf/black/issues/3407
A stable 23.1.0 release will follow in January 2023.
.gitignore
rules by considering the .gitignore
location
and the relative path to the target file (#3338).gitignore
presence when more than one source directory is
specified (#3336)any(match := my_re.match(text) for text in texts)
) (#3327).let g:black_use_virtualenv = 0
(#3309)