Update dependency black to v24 [SECURITY]
This PR contains the following updates:
| Package | Change | Age | Confidence |
|---|---|---|---|
| black (changelog) | 23.7.0 -> 24.3.0 |
||
| black (changelog) | ==23.7.0 -> ==24.3.0 |
GitHub Vulnerability Alerts
CVE-2024-21503
Versions of the package black before 24.3.0 are vulnerable to Regular Expression Denial of Service (ReDoS) via the lines_with_leading_tabs_expanded function in the strings.py file. An attacker could exploit this vulnerability by crafting a malicious input that causes a denial of service.
Exploiting this vulnerability is possible when running Black on untrusted input, or if you habitually put thousands of leading tab characters in your docstrings.
Release Notes
psf/black (black)
v24.3.0
Highlights
This release is a milestone: it fixes Black's first CVE security vulnerability. If you run Black on untrusted input, or if you habitually put thousands of leading tab characters in your docstrings, you are strongly encouraged to upgrade immediately to fix CVE-2024-21503.
This release also fixes a bug in Black's AST safety check that allowed Black to make incorrect changes to certain f-strings that are valid in Python 3.12 and higher.
Stable style
- Don't move comments along with delimiters, which could cause crashes (#โ4248)
- Strengthen AST safety check to catch more unsafe changes to strings. Previous versions of Black would incorrectly format the contents of certain unusual f-strings containing nested strings with the same quote type. Now, Black will crash on such strings until support for the new f-string syntax is implemented. (#โ4270)
- Fix a bug where line-ranges exceeding the last code line would not work as expected (#โ4273)
Performance
- Fix catastrophic performance on docstrings that contain large numbers of leading tab characters. This fixes CVE-2024-21503. (#โ4278)
Documentation
- Note what happens when
--checkis used with--quiet(#โ4236)
v24.2.0
Stable style
- Fixed a bug where comments where mistakenly removed along with redundant parentheses (#โ4218)
Preview style
- Move the
hug_parens_with_braces_and_square_bracketsfeature to the unstable style due to an outstanding crash and proposed formatting tweaks (#โ4198) - Fixed a bug where base expressions caused inconsistent formatting of ** in tenary expression (#โ4154)
- Checking for newline before adding one on docstring that is almost at the line limit (#โ4185)
- Remove redundant parentheses in
casestatementifguards (#โ4214).
Configuration
- Fix issue where Black would ignore input files in the presence of symlinks (#โ4222)
- Black now ignores
pyproject.tomlthat is missing atool.blacksection when discovering project root and configuration. Since Black continues to use version control as an indicator of project root, this is expected to primarily change behavior for users in a monorepo setup (desirably). If you wish to preserve previous behavior, simply add an empty[tool.black]to the previously discoveredpyproject.toml(#โ4204)
Output
- Black will swallow any
SyntaxWarnings orDeprecationWarnings produced by theastmodule when performing equivalence checks (#โ4189)
Integrations
- Add a JSONSchema and provide a validate-pyproject entry-point (#โ4181)
v24.1.1
Bugfix release to fix a bug that made Black unusable on certain file systems with strict limits on path length.
Preview style
- Consistently add trailing comma on typed parameters (#โ4164)
Configuration
- Shorten the length of the name of the cache file to fix crashes on file systems that do not support long paths (#โ4176)
v24.1.0
Highlights
This release introduces the new 2024 stable style (#โ4106), stabilizing the following changes:
- Add parentheses around
if-elseexpressions (#โ2278) - Dummy class and function implementations consisting only of
...are formatted more compactly (#โ3796) - If an assignment statement is too long, we now prefer splitting on the right-hand side (#โ3368)
- Hex codes in Unicode escape sequences are now standardized to lowercase (#โ2916)
- Allow empty first lines at the beginning of most blocks (#โ3967, #โ4061)
- Add parentheses around long type annotations (#โ3899)
- Enforce newline after module docstrings (#โ3932, #โ4028)
- Fix incorrect magic trailing comma handling in return types (#โ3916)
- Remove blank lines before class docstrings (#โ3692)
- Wrap multiple context managers in parentheses if combined in a single
withstatement (#โ3489) - Fix bug in line length calculations for power operations (#โ3942)
- Add trailing commas to collection literals even if there's a comment after the last entry (#โ3393)
- When using
--skip-magic-trailing-commaor-C, trailing commas are stripped from subscript expressions with more than 1 element (#โ3209) - Add extra blank lines in stubs in a few cases (#โ3564, #โ3862)
- Accept raw strings as docstrings (#โ3947)
- Split long lines in case blocks (#โ4024)
- Stop removing spaces from walrus operators within subscripts (#โ3823)
- Fix incorrect formatting of certain async statements (#โ3609)
- Allow combining
# fmt: skipwith other comments (#โ3959)
There are already a few improvements in the --preview style, which are slated for the
2025 stable style. Try them out and
share your feedback. In the past, the preview
style has included some features that we were not able to stabilize. This year, we're
adding a separate --unstable style for features with known problems. Now, the
--preview style only includes features that we actually expect to make it into next
year's stable style.
Stable style
Several bug fixes were made in features that are moved to the stable style in this release:
- Fix comment handling when parenthesising conditional expressions (#โ4134)
- Fix bug where spaces were not added around parenthesized walruses in subscripts, unlike other binary operators (#โ4109)
- Remove empty lines before docstrings in async functions (#โ4132)
- Address a missing case in the change to allow empty lines at the beginning of all blocks, except immediately before a docstring (#โ4130)
- For stubs, fix logic to enforce empty line after nested classes with bodies (#โ4141)
Preview style
- Add
--unstablestyle, covering preview features that have known problems that would block them from going into the stable style. Also add the--enable-unstable-featureflag; for example, use--enable-unstable-feature hug_parens_with_braces_and_square_bracketsto apply this preview feature throughout 2024, even if a later Black release downgrades the feature to unstable (#โ4096) - Format module docstrings the same as class and function docstrings (#โ4095)
- Fix crash when using a walrus in a dictionary (#โ4155)
- Fix unnecessary parentheses when wrapping long dicts (#โ4135)
- Stop normalizing spaces before
# fmt: skipcomments (#โ4146)
Configuration
- Print warning when configuration in
pyproject.tomlcontains an invalid key (#โ4165) - Fix symlink handling, properly ignoring symlinks that point outside of root (#โ4161)
- Fix cache mtime logic that resulted in false positive cache hits (#โ4128)
- Remove the long-deprecated
--experimental-string-processingflag. This feature can currently be enabled with--preview --enable-unstable-feature string_processing. (#โ4096)
Integrations
- Revert the change to run Black's pre-commit integration only on specific git hooks (#โ3940) for better compatibility with older versions of pre-commit (#โ4137)
v23.12.1
Packaging
- Fixed a bug that included dependencies from the
dextra by default (#โ4108)
v23.12.0
Highlights
It's almost 2024, which means it's time for a new edition of Black's stable style! Together with this release, we'll put out an alpha release 24.1a1 showcasing the draft 2024 stable style, which we'll finalize in the January release. Please try it out and share your feedback.
This release (23.12.0) will still produce the 2023 style. Most but not all of the
changes in --preview mode will be in the 2024 stable style.
Stable style
- Fix bug where
# fmt: offautomatically dedents when used with the--line-rangesoption, even when it is not within the specified line range. (#โ4084) - Fix feature detection for parenthesized context managers (#โ4104)
Preview style
- Prefer more equal signs before a break when splitting chained assignments (#โ4010)
- Standalone form feed characters at the module level are no longer removed (#โ4021)
- Additional cases of immediately nested tuples, lists, and dictionaries are now indented less (#โ4012)
- Allow empty lines at the beginning of all blocks, except immediately before a docstring (#โ4060)
- Fix crash in preview mode when using a short
--line-length(#โ4086) - Keep suites consisting of only an ellipsis on their own lines if they are not functions or class definitions (#โ4066) (#โ4103)
Configuration
--line-rangesnow skips Black's internal stability check in--safemode. This avoids a crash on rare inputs that have many unformatted same-content lines. (#โ4034)
Packaging
- Upgrade to mypy 1.7.1 (#โ4049) (#โ4069)
- Faster compiled wheels are now available for CPython 3.12 (#โ4070)
Integrations
- Enable 3.12 CI (#โ4035)
- Build docker images in parallel (#โ4054)
- Build docker images with 3.12 (#โ4055)
v23.11.0
Highlights
- Support formatting ranges of lines with the new
--line-rangescommand-line option (#โ4020)
Stable style
- Fix crash on formatting bytes strings that look like docstrings (#โ4003)
- Fix crash when whitespace followed a backslash before newline in a docstring (#โ4008)
- Fix standalone comments inside complex blocks crashing Black (#โ4016)
- Fix crash on formatting code like
await (a ** b)(#โ3994) - No longer treat leading f-strings as docstrings. This matches Python's behaviour and fixes a crash (#โ4019)
Preview style
- Multiline dicts and lists that are the sole argument to a function are now indented less (#โ3964)
- Multiline unpacked dicts and lists as the sole argument to a function are now also indented less (#โ3992)
- In f-string debug expressions, quote types that are visible in the final string are now preserved (#โ4005)
- Fix a bug where long
caseblocks were not split into multiple lines. Also enable general trailing comma rules oncaseblocks (#โ4024) - Keep requiring two empty lines between module-level docstring and first function or class definition (#โ4028)
- Add support for single-line format skip with other comments on the same line (#โ3959)
Configuration
- Consistently apply force exclusion logic before resolving symlinks (#โ4015)
- Fix a bug in the matching of absolute path names in
--include(#โ3976)
Performance
- Fix mypyc builds on arm64 on macOS (#โ4017)
Integrations
- Black's pre-commit integration will now run only on git hooks appropriate for a code formatter (#โ3940)
v23.10.1
Highlights
- Maintenance release to get a fix out for GitHub Action edge case (#โ3957)
Preview style
- Fix merging implicit multiline strings that have inline comments (#โ3956)
- Allow empty first line after block open before a comment or compound statement (#โ3967)
Packaging
- Change Dockerfile to hatch + compile black (#โ3965)
Integrations
- The summary output for GitHub workflows is now suppressible using the
summaryparameter. (#โ3958) - Fix the action failing when Black check doesn't pass (#โ3957)
Documentation
- It is known Windows documentation CI is broken #โ3968
v23.10.0
Stable style
- Fix comments getting removed from inside parenthesized strings (#โ3909)
Preview style
- Fix long lines with power operators getting split before the line length (#โ3942)
- Long type hints are now wrapped in parentheses and properly indented when split across multiple lines (#โ3899)
- Magic trailing commas are now respected in return types. (#โ3916)
- Require one empty line after module-level docstrings. (#โ3932)
- Treat raw triple-quoted strings as docstrings (#โ3947)
Configuration
- Fix cache versioning logic when
BLACK_CACHE_DIRis set (#โ3937)
Parser
- Fix bug where attributes named
typewere not accepted insidematchstatements (#โ3950) - Add support for PEP 695 type aliases containing lambdas and other unusual expressions (#โ3949)
Output
- Black no longer attempts to provide special errors for attempting to format Python 2 code (#โ3933)
- Black will more consistently print stacktraces on internal errors in verbose mode (#โ3938)
Integrations
- The action output displayed in the job summary is now wrapped in Markdown (#โ3914)
v23.9.1
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.
Packaging
- Upgrade to mypy 1.5.1 (#โ3864)
Performance
- Store raw tuples instead of NamedTuples in Black's cache, improving performance and decreasing the size of the cache (#โ3877)
v23.9.0
Preview style
- More concise formatting for dummy implementations (#โ3796)
- In stub files, add a blank line between a statement with a body (e.g an
if sys.version_info > (3, x):) and a function definition on the same level (#โ3862) - Fix a bug whereby spaces were removed from walrus operators within subscript(#โ3823)
Configuration
- Black now applies exclusion and ignore logic before resolving symlinks (#โ3846)
Performance
- Avoid importing
IPythonif notebook cells do not contain magics (#โ3782) - Improve caching by comparing file hashes as fallback for mtime and size (#โ3821)
Blackd
- Fix an issue in
blackdwith single character input (#โ3558)
Integrations
- Black now has an
official pre-commit mirror. Swapping
https://github.com/psf/blacktohttps://github.com/psf/black-pre-commit-mirrorin your.pre-commit-config.yamlwill make Black about 2x faster (#โ3828) - The
.black.envfolder specified byENV_PATHwill now be removed on the completion of the GitHub Action (#โ3759)
Configuration
๐ Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).
๐ฆ Automerge: Disabled by config. Please merge this manually once you are satisfied.
โป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
๐ Ignore: Close this PR and you won't be reminded about these updates again.
- [ ] If you want to rebase/retry this PR, check this box
This PR was generated by Mend Renovate. View the repository job log.
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code