#black-formatter

1 messages · Page 9 of 1

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Hi,

https://github.com/dmwm/deployment/blob/master/dmwmbld/github.py

Is throwing this error on the online formatter:

And using the latest black version on pip with a python docker:

Found input source: "dmwmbld/github.py"
Traceback (most recent call last):
  File "src/black/__init__.py", line 1517, in assert_equivalent
  File "src/black/parsing.py", line 156, in parse_ast
SyntaxError: multiple exception types must be parenthesized (, line 20)

During handling of the above exception, an...
flat krakenBOT
#

Description

This PR removes outdated instructions for installing the Black VIM plugin from the documentation (editors.md). The previous guidance suggested running git checkout origin/stable -b stable after installing via Vundle, but this command fails because origin/stable is not a valid branch or tag. Since Black works without this step, removing it will prevent confusion for users following the installation inst...

modern drift
#

This is not place for advertising

#

@heavy summit

heavy summit
#

!ban @dire tulip spam across multiple channels

late dewBOT
#

:incoming_envelope: :ok_hand: applied ban to @dire tulip permanently.

silent knoll
#

@warm vigil advertising ^

warm vigil
#

!cleanban 543104385098579999 advertising

late dewBOT
#

:incoming_envelope: :ok_hand: applied ban to @viral dragon permanently.

flat krakenBOT
flat krakenBOT
#

Description

Not sure on the policy for updating versions, so to cope with the new click 8.3.0 version I used some code from #4577 for version conditional behavior. When >= 8.3.0, unset defaults are now the special UNSET sentinal instead of None. Hopefully nothing breaks on the click._utils usage since it's an _ module, might have to find a different solution if it does.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, f...
flat krakenBOT
#

Description

It's been a long time since the last release, so lets get one done.

I moved the entry about async/await to highlights since it could affect some people, despite being fine to do.

I also need to go back and do some updates to both release.py and the docs, since I ran into a couple issues that could be smoothed over.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, following the
    stability polic...
flat krakenBOT
#

Description

Git by default uses utf-8 file encodings, so these files will always be utf-8. On a windows system without PYTHONUTF8 set, these opens will fail (normal black doesn't have this issue because it detects file encodings automatically).

This PR makes it so that the opens always use utf-8 mode, so the script will always work on windows systems.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, following the
    ...
#

Description

When making these previously I forgot to add the multiline flag that makes them work.

I prefer using (?m) instead of re.Multiline for flags, since when reading a regex it's a lot more obvious, being placed at the beginning instead of the end.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, following the
    stability policy?
  • [N/A] Add an entry in CHANGES.md if necessary?
  • [N/A] Add / update tes...
flat krakenBOT
flat krakenBOT
#

Description

When originally making the change, I assumed we were having a release in Feb, so I put the number as 25.2.0. Since that didn't happen, the number needs to be changed to 25.9.0.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, following the
    stability policy?
  • [N/A] Add an entry in CHANGES.md if necessary?
    • Changing one number, shouldn't need an entry
  • [N/A] Add / update tests if necessary?
    -...
flat krakenBOT
flat krakenBOT
#

While cutting 25.9.0, I ran into a few snags, so this PR smooths out the issues I ran into in the docs:

  • Minor typo fix
  • Since the stable branch is updated by the release workflow, git diff origin/stable CHANGES.md should always work, which is much easier than having to find a commit hash
  • The example PR given had the new template already applied, which confused me. I eventually used the 25.1.0 PR as a reference instead
  • GitHub appears to now use the last commit message as the rel...
flat krakenBOT
#

Describe the bug

When upgrading to black==25.9.0 (from 25.1.0), I get the following error for every file when running flake8:

BLK900 Failed to load file: decode_bytes() missing 1 required positional argument: 'mode'

To Reproduce

$ pip install black==25.9.0
$ flake8 src/
 BLK900 Failed to load file: decode_bytes() missing 1 required positional argument: 'mode'
$ pip install black<25.9.0

$ flake8 src/

flake8 and flake8-black (and flake8-*...

flat krakenBOT
#

Description

After talking for a bit on the click discord, I was pointed to the to_info_dict function.

Since the functionality of to_info_dict was preserved between 8.2.0 and 8.3.0, using it makes the code much cleaner while having the same effect.

Theoretically, the entirety of the function could re-use to_info_dict, but there are two problems: No is_eager detection, and it's currently untyped besides dict[str, Any], so I decided against it and just did the one ...

flat krakenBOT
#

flake8 is reporting that there is an error in black version 25.9.0 src/black/__init__.py

BLK900 Failed to load file: decode_bytes() missing required argument 'mode' (pos 2)

Example of error:

Yesterday, the following changes to black were made public:

silent knoll
#

The multiline_string_handling docs says it combines strings like these:

s = (
    "An "
    "implicit "
    "multiline "
    "string"
)

s = (  # Top comment
    "An "
    "implicit "
    "multiline "
    "string"
    # Bottom comment
)
``` But it doesn't.

They *are* merged on `--unstable`, which is a little odd because the `string_processing` docs say "User-made splits are respected when they do not exceed the line length limit."
azure plank
#

:/ I guess those are technically fixed, but I was leaving them open since none of the actual issues were fixed, just made inaccessible by 4498, so if we ever go back to implementing f-string formatting we'll just run into all of them again

silent knoll
#

oh i see, sorry

azure plank
silent knoll
#

ah yeah

#

i was working on a PR to move multiline_string_handling to preview (since I've fixed everything that can be, and now that fix is released) and I noticed that

azure plank
#

Ah, you noticed that in your move to preview code?

silent knoll
#

yeah

azure plank
#

Makes sense that it was missed, since the combination of those two has been a massive mess.

silent knoll
#

i mean, on its own multiline_string_handling is fine

#

it's odd that according to the docs they did opposite things with implicitly concatenating strings

azure plank
#

I'm not sure if the docs on string_processing are at all correct anymore with the amount of changes that happened

silent knoll
#

i think it is other than that

#

the docs there are pretty broad

flat krakenBOT
#

Description

In #4657, I fixed most issues with multiline_string_handling. Now that the fixes have been released, I think it makes sense to move it back to --preview for the next release, and hopefully into stable for v26.

As detailed in https://github.com/psf/black/issues/4159#issuecomment-2661780172, there is no good way to auto-fix the now unaligned indentation in multiline strings, and hopefully moving this feature to --preview will help us gather thoughts from users.
...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

This happened because the code didn't account for comments before module docstrings. Since there can be arbitrarily many, this PR pulls the check into a new function so a while loop could go through all the previous blocks until either the start of the file is found, or a non comment block is reached.

A new test was added.

Fixes #4762

Code put in preview to not change the stable style.

Checklist - did you ...

  • [x] Implement any code style cha...
flat krakenBOT
#

Description

This PR updates the project's configuration to align with the recommendations from PEP 639 regarding license management in Python projects. The following changes have been made:

  • Removed classifiers starting with License::
  • Added the license field with an SPDX expression, in compliance with PEP 639
  • Added the license-files field to list license files, also in accordance with PEP 639
  • Updated the minimal version of hatchling

These changes aim to improve the projec...

flat krakenBOT
#

Description

Created a quick check to ignore #\r in Fuzz unless the appropriate Preview flag is on. Hopefully fixes the Fuzz errors.

Checklist - did you ...

  • [y] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

The required-version configuration param supports two different "modes": exact version or major-version-only.
The GitHub Action workflow currently reads this parameter from pyproject.toml when configured with use_pyproject: true in order to determine what version of black to pip install. However, this fails when pyproject.toml is configured with the "major-version-only" ...

fierce wagon
#

yo what's up guys?

#

I am new

#

Can anyone tell me what's going on?

#

I might help

slate remnant
flat krakenBOT
#

I swear this isn't just an advertisement for my youtube video... but along the same lines of my youtube video multiprocessing: slow things first I believe there's some optimization potential to the scheduling of files for black

I initially thought about this a bit when receiving a report from freecad about slow execution of black in pre-commit.ci -- (sorta unrelated to this) after looking into it I noticed two significant ...

idle grail
#

I just met Łukasz in person at PyCon Estonia, great guy :D

flat krakenBOT
#

Description

Refactor the vim plugin error message for unsupported versions.

It now handles independently outdated vim version and python feature missing so that the message provides more meaningful information to the users.

Fixes #4437

Checklist - did you ...

  • [X] Implement any code style changes under the --preview style, following the
    stability policy?
  • [X] Add an entry in CHANGES.md if necessary?
  • [X] Add / update tests if necessary?
  • [X...
#

Description

Add Ubuntu-22.04 for arm as builder.

This will allow people using arm based machines to have access to the black binary in the same fashion as for x86_64.

Fixes #4418

Checklist - did you ...

  • [X] Implement any code style changes under the --preview style, following the
    stability policy?
  • [X] Add an entry in CHANGES.md if necessary?
  • [X] Add / update tests if necessary?
  • [X] Add new / update outdated documentation?
flat krakenBOT
#

Description

blackd does not have a client yet (as written in the documentation). @maludwig provided one in #3721.

I refactored it a bit to use aiohttp to avoid adding a new dependency and cleaned it to match coding standard used in black.

This class allows to easily send code to be formatted by blackd.

Fixes #3721

Checklist - did you ...

  • [X] Implement any code style changes under the --preview style, following the
    stability policy?
  • [X] Add a...
flat krakenBOT
flat krakenBOT
#

Description

This PR implements symmetric formatting for multi-line list concatenations, addressing #260.

When an assignment’s right-hand side (RHS) is a concatenation of two list displays or list comprehensions and the statement would exceed the configured line length, Black wraps the RHS in parentheses and breaks it symmetrically with the + at the beginning of the next line.

Before

search_fields = ["file__%s" % fi...
flat krakenBOT
#

Fix type parameter expansion when function parameters have trailing comma

Fixes #4740

Problem

When a function with type parameters has a trailing comma in its parameter list, Black incorrectly expanded the type parameter brackets instead of the function parameter list:

Before:

def func1[T: (int, str)](a,): ...

# Formatted to (incorrect):
def func1[
    T: (int, str)
](a,): ...

After:

def func1[T: (int, str)](a,): ...

# Formats to (...
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

While Black leaves the following unchanged under preview:

if True: print("this") # fmt: skip

and the following unchanged even without preview:

print("this"); print("that") # fmt: skip

it does not seem to leave the combination of these unchanged - see below.

Black https://github.com/psf/black/commit/314f8c

[Playground link](https://black.vercel.app/?version=main&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AC2AHBdAD2IimZxl1N_Wlws4TBexXdsrAK05TP_h68mLfXhiR6xhp...

flat krakenBOT
#

Description

Trying the change from #4771 , I'd like to see if this helps reduce the diff-shades runtime, since the 22% speed increase from #4771 could be enough to make the action consistent again.

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
    ...
flat krakenBOT
#

Description

I did more digging on the issue with diff-shades, and apparently the latest ubutnu has some stability issues? Some people reported successes by pinning to ubuntu-22.04 (which is the last stable version instead of latest, see https://github.com/actions/runner-images ) So this PR trys doing that. I'm not sure if I needed to update it in all the places I did, but I just chose to do all the latests in the shades workflow files to hopefully not get any problems from di...

flat krakenBOT
#

Description

blib2to3.conv cannot currently be imported. This change allows it to be imported.

I don't see that module used anywhere, so the correct fix might actually be to remove the file?

If it is not used, it probably doesn't need tests or a description in CHANGES.md, or other documentation.

Checklist - did you ...

  • [x] Implement any code style changes under the --preview style, following the
    stability policy?
  • [x] Add an entry in CHANGES.md if necessar...
shrewd dock
#

isnt ruff just better

#

i liked ruff a lot more

lyric kite
# shrewd dock isnt ruff just better

thats a subjective opinion, i think both have their pro's and con's, so its probably something else for everyone. Like some people don'teven used formatters, or make their own private ones

azure plank
# shrewd dock isnt ruff just better

It depends on what means “better” to you.
I am a big fan of the Astral projects in general, and have worked on them a decent amount, but the main pull to Black for me is that it’s written in python. If I want to read what it does, or hack around on it, it is much easier than Rust, which is why I because a helper on the project.
It’s also simpler, I don’t really care about regularly linting my code, but I do like it formatted.
Ruff’s style is also based on black, for a reason. It’s nice to have a consistent style that matches what you find across a large part of the python ecosystem, and while ruff is mostly the same there are some differences to black.

shrewd dock
azure plank
#

Also for the record, we are aware that blacks performance is not the best, and (at least I) will be looking into trying to improve it a bit, especially in the preview/unstable styles as it’s starting to affect one of the ci actions.

mint barn
#

welp

flat krakenBOT
#

Description

Fix dark mode readability in documentation code blocks.

Update furo theme in docs/requirements.txt from:

furo==2025.7.19

to:

furo==2025.9.25

Checklist - did you ...

  • [x] Implement any code style changes under the --preview style, following the
    stability policy?
  • [x] Add an entry in CHANGES.md if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
pearl geyser
#

wat dis

azure plank
# pearl geyser wat dis

This is the channel for tracking the development of and talking about the black formatter. See the channel description for more information.

flat krakenBOT
flat krakenBOT
#

Description

Added supported python versions badge on readme documentation which will directly fetch version information from pypi project's classifier section.

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

I'm a consultant working with a client who overrides black's default line length and uses 119. I prefer the default of 88. They have the longer line length set up in their pre-commit. I auto-format the code to the length of 88 to make my code easier to read, but when the pre-commit gets applied, it lengthens lines.

Describe the solution you'd like

I'd like an option to tell black "do not make lines longer", or "only ...

flat krakenBOT
#

Describe the bug

Black 25.9.0 release added a dependency on pytokens package. This prevents distributions from packaging new black version, given that the source distribution on PyPI is incomplete and there are no tags on the repository. Given the latter, this dependency additionally raises supply chain security concerns.

Both issues were reported upstream on Sep 19 (https://github.com/tusharsadhwani/pytokens/issues/3, https://github.com/tusharsadhw...

flat krakenBOT
#

Describe the bug

black doesn't support Python 3.14 syntax.

To Reproduce

For example, take this code:

name = "world"
print(t"hello {name}")

And run it with these arguments:

$ black file.py --target-version py314

The resulting error is:

error: cannot format t_string.py: Cannot parse for target version Python 3.14: 3:7: print(t"hello {name}")

Expected behavior

I expect black to be able to parse this.

Environment

  • Black's version: 25.9.0
  • OS...
flat krakenBOT
#

Description

Created when building with mypyc. I was surprised they weren't already ignored, please let me know if there was a reason.

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [-] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?
#

Description

This (partially) reverts commit 24f516961720c5578069dee30415b776359b7be5.
(The grammar changes weren't reverted)

Band-aid solution just to fix diff-shades crashing until we can get the unstable style sped up.

Checklist - did you ...

  • [y] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [y] Add new / update outdated document...
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

When making changes to Black's source, including when switching between branches, it's necessary to manually clear the cache directory to view the changes in formatting.

Describe the solution you'd like

A --no-cache option to bypass reading from the cache. This would make development much faster for me.

Describe alternatives you've considered

Additional context

Should this flag also bypass writing t...

flat krakenBOT
flat krakenBOT
#

Although this doesn't change the stable style and doesn't need to be in the preview style, I think I'd prefer to have it there for consistency anyway. That could be done just by returning early inside _find_compound_statement_context if Preview.fix_fmt_skip_in_one_liners in mode. The preview feature already exists, so you shouldn't need to do anything else with that.

The similar issues #4782 and #4781 currently cause crashes with fix_fmt_skip_in_one_liners - would it be difficult to fi...

flat krakenBOT
#

Description

closes: #4802

  • Adds a --nocache CLI flag that disables both reading from and writing to Black's on-disk cache.
  • When set, Black performs fresh analysis for every file (no cache filtering) and never updates the cache file.
  • Includes a unit test

Checklist -

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [x] Add / update tests if necessary?
    -...
flat krakenBOT
flat krakenBOT
#

Description

  • State in pyproject that we somewhat work in 3.14
  • Enable py314 tox
  • Add base testing action so we don't regress

Note: We don't support some 3.14 grammar/parsing still

Test:

  • Install in 3.14 and format something
MacBookPro:black cooper$ python3 -V
Python 3.14.0
MacBookPro:black cooper$ python3 -m venv --upgrade-deps /tmp/tb
t/mp/MacBookPro:black cooper$ /tmp/tb/bin/pip install -e .
...
MacBookPro:black cooper$ time /tmp/tb/bin/black ../bandersnat...
neon loom
#

Welcome all feedback - Prob have some docs to update ...

flat krakenBOT
flat krakenBOT
#

This PR adds module-level docstrings to the init.py files in the Black repository
(src/black/init.py and src/blackd/init.py) to improve documentation of
preview-style features.

Changes include:

  • src/black/init.py: Added a docstring explaining the purpose of the module
    and how it sets up the Black web application for formatting previews.
  • src/blackd/init.py: Added a docstring describing its role in the Black
    server-side functionality.

These updates are...

whole summit
flat krakenBOT
lilac perch
#

Hi , I just tryed to understand the tests/data/cases/allow_empty_first_line.py

Like input and output looks the same . Can someone explain what this file is about .

azure plank
flat krakenBOT
lilac perch
#

@azure plank there is a async edge case file inside cases . I can create a new file async_more_cases.py or I can continue with the existing one?

azure plank
lilac perch
#

OK ✌️

#

I'm just starting to explore tho.

flat krakenBOT
flat krakenBOT
#

Description

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?

Description

Added small edge-case tests for async functions to verify Black's formatting:

  • Async functions with default parameters
  • Async tuple unpacking in async for l...
lilac perch
#

@azure plank I just tryed to add a case . So the pr is closed stating that, this change isn't necessary .

What does it Mean actually .

azure plank
# lilac perch <@336710069498544148> I just tryed to add a case . So the pr is closed stating ...

The problem with your PR is that there isn't a clear thing it's trying to fix/improve. Adding a case as a regression test for a issue the PR is fixing makes sense, but just adding cases to add them doesn't. This functionality should already be covered by the normal function cases, and the few async cases are there as a sanity check to make sure it still works. We have a bunch of issues still open with bugs that need fixed, so everyone's effort (including yours) would be better focused on those.

lilac perch
#

Ohh got it. It's my first action in a open source 😅.

#

I need to try to understand the purpose of black and how it actually works

silent knoll
#

What's more, I'd advise trying to understand the codebase, writing code, and the PR description yourself instead of just plugging things into an AI without checking what it's doing, because AI tends to provide low quality code inconsistent with our repository structure

azure plank
#

The purpose is pretty simple - a minimal options python formatter. We don't currently have the best internal docs on how the code works, so the best way would be to find an issue that looks interesting to you, and then find and read the code around where the issue is, and once you understand at least that portion make a change, add tests as nessacary, follow all the instructions in the PR description template/contributing docs, and only then open a PR.

lilac perch
#

Yeah got it .

lilac perch
azure plank
# lilac perch But I can use ai to understand things right? Like use help of that tool ..to und...

We mostly just ask that you understand the code you write/submit. "The AI did it" is not an excuse for submitting code you do not understand, or for not following our processes, so as long as you fully understand the code you write/submit, and follow all of our contributing steps, using AI just as a tool is irrelevant, as long as you understand both what you are doing, and where AI can go wrong.

lilac perch
#

Yeah , um I don't know how to sa y it . But yeah I get what your saying . Thanks

#

So @azure plank so today , I went up looking this issue just tryed to read .
Black doesn't merge raw strings effectively . I know what a raw string is (basic level).
I understand the issue. But when getting to think how to solve I have no idea, in this case where should I start?

azure plank
#

The code for string processing lives in src/black/trans.py. The way I generally start debugging an issue is using a debugger like pdb + print statements to find where in the code the issue is happening.

lilac perch
#

Oh thanks. So there is this file string.py ..I just went opening that and was just reading . Idk how to move further.

azure plank
#

strings.py only deals with very basic string formatting, trans.py deals with transforming/merging strings.

lilac perch
#

oh ok I'll read it again tmrw and try to understand what I can

#

But that issue was Like 2023.....

azure plank
#

You should double check if the issue is still happening, but it probably is, since last year I went through and cleaned up most of the already fixed issues.

lilac perch
#

And I can ask any doubts here regarding this

silent knoll
#

Of course

flat krakenBOT
#

Description

This fixes issue #1245 where comments between # fmt: off and # fmt: on directives were being reformatted even though they should be left untouched. Additionally, it fixes the inconsistent behavior where comments
containing fmt directives (like #fmt:skip) were being normalized even though the directive's purpose is to prevent formatting.

Root Causes:

  1. When ONLY comments exist between fmt directives (no code), generate_ignored_nodes() returns empty...
flat krakenBOT
#

Updated information regarding support for ignoring revisions in GitLab.

Here are the relevant updated information:
https://about.gitlab.com/releases/2025/03/20/gitlab-17-10-released/#ignore-specific-revisions-in-git-blame - release docs describing this feature.
https://gitlab.com/groups/gitlab-org/-/epics/15751 - The epic which the previously linked issue was promoted into, now complete but staying open for enhancements.

I did not go into depth into which enhancements are missing, yet...

flat krakenBOT
flat krakenBOT
#

Description

Closes #4813

This would add native arm64 wheel and binary builds as well as add add arm64 windows to the ci tests and the release tests.

Checklist - did you ...

  • [x] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
flat krakenBOT
flat krakenBOT
bright glacier
#

Hacktoberfest?

silent knoll
#

yeah

plain atlas
#

Tbf it does look better

#

Also should add rst to the rst codeblock while at it

#

Mind if I make a PR for that?

flat krakenBOT
flat krakenBOT
#

Describe the bug

When an @overload function is inside a class, the parser bugs out only when using the --line-ranges argument. This bug does not happen when the @overload function is outside of a class however.

To Reproduce

Take this code:

from typing import Union, overload


class Test:

    @overload
    def test(self, a: str, b: str) -> str: ...

    @overload
    def test(self, a: str, b: int) -> int: ...

    def test(self, a: str, b: Union[str, int]):
        prin...
flat krakenBOT
flat krakenBOT
plain atlas
#

thanks jelle

flat krakenBOT
silent knoll
#

hacktoberfest is over now so might as well do it ourselves & merge it

flat krakenBOT
plain atlas
#

agree; I only waited until hacktoberfest was over to make the above pr cause i wanted to make sure it was known i wasn't doing it for hacktoberfest lol

silent knoll
#

lol fair enough

plain atlas
#

i even made the commit four days ago

little parrot
#

is there a way to have a trailing comma always break a line

silent knoll
flat krakenBOT
#

Is your feature request related to a problem? Please describe.
Yes. When black encounters a Python file with a syntax error, the current error message is often dense, confusing, and can point to the wrong line. This forces the developer to spend extra time deciphering what went wrong and where.

Describe the solution you'd like
I propose enhancing the error reporting for SyntaxErrors to be more user-friendly, clear, and actionable.
Instead of the current one-line error, black coul...

little parrot
silent knoll
#

sounds like a bug, i can look into it more later, you can make an issue if you want

flat krakenBOT
#

Looked through the code, everything looks good! Thanks for your hard work on this!

My understanding is that formatting t-strings previously crashed, and this fixes the crash without changing formatting of code that already was successfully formatted. Is that correct? Otherwise this will have to be preview-gated

flat krakenBOT
plain atlas
plain atlas
#

(this also impacts the custom builder on pip)

azure plank
plain atlas
#

Yeah it does impact the changelog but trying to see if a patch would break anyone

flat krakenBOT
#

Description

  • Fix fix_fmt_skip_in_one_liners crashing on with statements (fixes #4785)
  • Fix fix_fmt_skip_in_one_liners crashing on annotated parameters (fixes #4781)
  • Fix fmt: skip skipping the line after instead of the line it's on (fixes #3364, fixes #4366)
    • Implemented in the stable style, it doesn't change previosuly-formatted code

Checklist - did you ...

  • [y] Implement any code style changes under the --preview style, following the
    ...
flat krakenBOT
#

When using the prebuilt binary on Mac I am seeing the following:

INFO: Running command line: /private/var/tmp/_bazel_fp/01684213bb9c693047272ec8f0247481/external/+_repo_rules+black_macos/file/downloaded 
All done! ✨ 🍰 ✨
575 files left unchanged.
Traceback (most recent call last):
  File "__main__.py", line 1, in 
  File "", line 1360, in _find_and_load
  File "", line 1331, in _find_and_load_unlocked
  File "", line 935, in _load_unlocked
  File "pyimod02_importers.py", line 457, in exec...
flat krakenBOT
#

Description

Add optional output-file input to write Black output to a file in addition to stdout. This allows GitHub Actions workflows to capture structured Black output without cluttering job logs.

Changes

  • New output-file input parameter (optional, default: empty string)
  • Output written to file relative to repo root when specified
  • Full stdout/log output preserved - file write is in addition to, not instead of
  • Exit code and behavior unchanged
  • Prope...
flat krakenBOT
neon loom
plain atlas
#

That's what it looks like

#

!pypi pytest

late dewBOT
#

pytest: simple powerful testing with Python

Released on <t:1762622733:D>.

plain atlas
#

!pypi pluggy

late dewBOT
#

plugin and hook calling mechanisms for python

Released on <t:1747312207:D>.

plain atlas
#

The error seemed to be in pytest which was just updated

neon loom
#

O nice find, I'll try in a bit, deep in another PR for another project

plain atlas
#

You're good, tested locally and will open a PR

neon loom
#

Legend. Then we need to workout what to do about a cp314 build

plain atlas
late dewBOT
#

tests/optional.py line 70

ot_ini = config.inicfg.get("optional-tests") or []```
plain atlas
#

(9.0 rewrote config and added PROPER pyproject.toml [tool.pytest] support 🎉)

neon loom
flat krakenBOT
#

I'm not sure why its returned as an internal error when it happens in testing code, so that's also a bit odd. Might have to open a pytest issue as well.

Configuration was updated in pytest 9.0 (which now supports [tool.pytest] without the legacy ini_options in pyproject! :tada:) but that seems to break testing for black.

py: commands[2]> pytest tests --run-optional no_jupyter --numprocesses auto --cov
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/qt/...
neon loom
#

Boo - that action still uses latest pytest

plain atlas
#

which one

#

ok fixed

#

why does it hate me right now lmao

#

i got three errors locally lmao

#

think i got it, ci seems to be running now

neon loom
#

If so, this is on purpose as we still support 3.9

plain atlas
#

I don't know. I see the error on the commit seems to be coming from my fork lmao

#

I had actions enabled on my fork from a few years ago when i debugged the release workflow..... ...lol

#

i just keep fixing black ci right before a release 😆

neon loom
#

And we appreciate it ❤️

plain atlas
#

turned off my own ci, only thing running now seems to be diff shades, so i think its good

flat krakenBOT
neon loom
#

Now, anyone around who understand how we get a cp314 build to save me reverse engineering?

neon loom
#

I guess I should be clearer, should we maybe move CI to do one so we know we have a better chance of releasing a successful one?

plain atlas
#

ahhh

neon loom
late dewBOT
#

.github/workflows/pypi_upload.yml line 78

CIBW_BUILD: "cp39-* cp313-*"```
plain atlas
#
  • pip install 'pytest>=6.1.1,<9.0'
    The system cannot find the file specified.
    what is that lmao
neon loom
neon loom
# plain atlas no need. main is broken on a supported platform. -# actually it was already brok...

Super weird:

cooper@cooper-fedora-MJ0J8QHP:~/repos/bandersnatch$ .venv/bin/pip install 'pytest>=6.1.1,<9.0'
Collecting pytest<9.0,>=6.1.1
  Using cached pytest-8.4.2-py3-none-any.whl.metadata (7.7 kB)
Collecting iniconfig>=1 (from pytest<9.0,>=6.1.1)
  Using cached iniconfig-2.3.0-py3-none-any.whl.metadata (2.5 kB)
Requirement already satisfied: packaging>=20 in ./.venv/lib64/python3.13/site-packages (from pytest<9.0,>=6.1.1) (25.0)
Requirement already satisfied: pluggy<2,>=1.5 in ./.venv/lib64/python3.13/site-packages (from pytest<9.0,>=6.1.1) (1.6.0)
Collecting pygments>=2.7.2 (from pytest<9.0,>=6.1.1)
  Using cached pygments-2.19.2-py3-none-any.whl.metadata (2.5 kB)
Using cached pytest-8.4.2-py3-none-any.whl (365 kB)
Using cached iniconfig-2.3.0-py3-none-any.whl (7.5 kB)
Using cached pygments-2.19.2-py3-none-any.whl (1.2 MB)
Installing collected packages: pygments, iniconfig, pytest
Successfully installed iniconfig-2.3.0 pygments-2.19.2 pytest-8.4.2
cooper@cooper-fedora-MJ0J8QHP:~/repos/bandersnatch$ 
#

Ahh missed it's only Windows

#

I don't haz a windows

plain atlas
#

I do but i'm on linux and i sort of should be working on homework if i boot into windows

silent knoll
#

found the windows issue, making a pr

#

actually, this is more difficult than i thought to fix

#

windows ✨

bright glacier
#

Could you consider using a constraints file and pass that via ${project}/constraints.txt or whatever so you don't need to split the configuration between Unix/Windows?

#

CIBW_TEST_REQUIRES_WINDOWS ah, this exists

#

that's probably easier than using a constraints file

silent knoll
#

tbh, i'm not super familiar with how cibuildwheel works
right now it reads the requires from tool.cibuildwheel.test-requires in pyproject.toml, so i'm not sure the best way to override it

plain atlas
silent knoll
#

does anyone know if we could just install pytest ourselves?

plain atlas
#

right now we have ci pass on the pull requests but fail on main

silent knoll
#

better question, why aren't all wheels always built?

bright glacier
silent knoll
#

diff-shades takes 15 minutes on its own

#

each wheel takes 3

plain atlas
#

and concurrency limitations. orgs have a specific limit of actions they can run across the entire organisation at once. PSF undoubtably has higher limits on an open source software plan (presumption of mine), but there's still limitations

silent knoll
#

ah that's fair enough then

plain atlas
#

in a basic org you can only run on 5 mac os runners at a time 😭

bright glacier
#

I actually don't think the psf github organisation is special.

plain atlas
#

!remind 6D why is docker slow ><

late dewBOT
#
Absolutely!

Your reminder will arrive on <t:1763250365:F>!

silent knoll
bright glacier
#

That's up to you

#

In general, I expect the envvar to be only temporary so I don't think it matters as it'll be removed at some point.

plain atlas
#

insane

#

E assert '1 file would be left unchanged.' in "error: cannot format D:\a\black\black\tests\data\jupyter\notebook_without_changes.ipynb: [Errno 13] Permission denied: 'C:\\Users\\runneradmin\\AppData\\Local\\black\\black\\Cache\\0.1.dev1+g42a7f6b99\\cache.-.88.1.0.0.0.1.0.0.@.pickle'\n\nOh no! 💥 💔 💥\n1 file would fail to reformat.\n"
E + where "error: cannot format D:\a\black\black\tests\data\jupyter\notebook_without_changes.ipynb: [Errno 13] Permission denied: 'C:\\Users\\runneradmin\\AppData\\Local\\black\\black\\Cache\\0.1.dev1+g42a7f6b99\\cache.-.88.1.0.0.0.1.0.0.@.pickle'\n\nOh no! 💥 💔 💥\n1 file would fail to reformat.\n" = <Result SystemExit(123)>.output
well that's better

#

its a weird permissions error instead of something else

silent knoll
#

the other windows ones succeed so may be one-off

plain atlas
silent knoll
#

ooh

#

sorry theres a lot of workflows to keep track of

plain atlas
#

ci is extensive (and for good reason)

silent knoll
#

(they fix different errors)

flat krakenBOT
plain atlas
#

release process: incremental fixes until it works

#

wait that's just programming in general

silent knoll
plain atlas
#

i got the same thing locally

#

but it works in ci

silent knoll
#

yeah it works on psf/black ci but failed on the commit to my fork

plain atlas
#

yeah

#

my solution was to disable ci on my fork

flat krakenBOT
silent knoll
#

oops, sorry didn't see your review @elder tusk

elder tusk
#

no worries at all, thanks for finding the fix!

plain atlas
#

aight if you make a label called ci: build all and give it to psf/black#4833 it should build all wheels on that pr and then we can merge + add the label to the other big ci changes which means wi'll build the wheels that are failing on the prs themselves

plain atlas
#

what in the how did i trigger lance twice

silent knoll
#

"psf/black#4833"

toxic stormBOT
silent knoll
#

and the edit probably made it run twice

plain atlas
#

yeah cause i edited before it suppressed

#

i don't know how that happened

#

it shouldn't have happened at all lmao

elder tusk
#

hmm the caret isn't fixing

#

getting " The syntax of the command is incorrect."

silent knoll
#

hmm

elder tusk
#

trying some variants...

plain atlas
#

rebased and squashed 4833 (the label)

silent knoll
plain atlas
#

we uh politely ask pytest to yank 9.0.0? /j

elder tusk
#

pytest nein

#

okay great, my latest attempt seems to be good

silent knoll
#

i mean idk if there's any reason why we can't do pytest~=8.0

plain atlas
#

repackagers i think

#

psf/black#4833 looks ready for merge

toxic stormBOT
plain atlas
#

as in: ci is half red lmao

flat krakenBOT
silent knoll
#

haha

plain atlas
#

its funny when this is a good thing

silent knoll
#

on main, pytest was successfully instealled on windows and is currently running tests 🎉 a very good sign

flat krakenBOT
silent knoll
#

haha that's slightly annoying

plain atlas
#

welp

#

probably should have tried that first, sorry :^)

elder tusk
#

lol, no thank you for everything. usually the unblock is faster than the fix...

plain atlas
#

i wonder if I can make ci: build all wheels a little more sound... hm

#

but i think adding a trigger of labeled is probably going to create a lot more ci noise

silent knoll
#

probably more work than necessary

plain atlas
#

yeah

#

should at least document it for the release PRs

#

and that bug in pytest 9.0 seems like a bug in pytest: I don't think that pytest should be reporting user code as an internal error, it seems odd

#

(i mean yes, its also a bug in the black test suite, but the INTERNAL ERROR prefix seems like a pytest bug)

elder tusk
#

huh, hit one more issue, only reproes when using pytest-xdist and pytest>=9, fixing...

plain atlas
#

don't forget the label

#

you mean pytest 6, right?

#

I'm actually somewhat confused here lol

silent knoll
#

yeah probably

#

the code that was removed was for "pytest < 7"

plain atlas
#

ah gotcha

neon loom
#

Nice all - Thanks for the effort while I was off

#

Should I rebase and merge the relese diff and cut one?

#

I'll let all the actions on main pass, then I will if all good

#

Happy Monday for a lot of people

#

Hopefully not noise / bugs 😄

plain atlas
#

wow.... all of my contributions to black have resulted in approximately a +14, -11 diff.

#

That's hilarious to me

plain atlas
neon loom
#

Will make the Python team @ meta happy (my employer)

plain atlas
#

-# even though I don't use black anymore its still fun :D

neon loom
#

I haven't been in the python team for years but thanks all for getting it through

neon loom
#

(I got pinged to try help make a release happen by a friend)

plain atlas
#

i'm all for faster tooling buuut I'm also very much for competition and pure python tools

#

astral moved some of its ci to a closed source bot recently so that's definitely raising a few flags for now

neon loom
#

Haven't been watching, but that seems to go against their claimed ethos etc.

plain atlas
neon loom
#

I'm just happy the effect black has had on python code globally

plain atlas
#

black still beats ruff some times

neon loom
#

O really, that I did not know

#

ichard's compiling was huge

plain atlas
#

I sometimes use uvx black --unstable to fix a lint error in ruff lmao

#

oh not timewise but style wise

#

getting that merge of implicit string concatenation is huge

neon loom
#

It's the "black" style for a reason 😄

#

Many hours ambv, myself and some other co-workers argued on a whiteboard

plain atlas
#

its three characters I have to manually delete i don't wanna do that 😭

#

easier to run black :D

neon loom
#

black alone is more chars ... just saying

plain atlas
#

mhm

#

but consider: additional black changes that make code even darker than it was before

flat krakenBOT
plain atlas
#

-# now we wait for ci again

neon loom
#

Yeah, have a draft release ready to go

#

I will once Build and Publish looks good

#

Won't wait for docker

plain atlas
#

lmao

neon loom
#

I need to see if I can make that faster one day, fuck me it's slow

plain atlas
neon loom
#

I forget what makes the compile so slow apart from the 1 CPU actions container ... I wonder if I can just get us a tougher container to run that in

plain atlas
#

(I set a reminder to look at docker builds next weekend)

neon loom
#

Ahh ok, yeah I made it slow when I turn on compiling in the container

#

But didn't debug the main reason it went so slow

flat krakenBOT
plain atlas
#

i was going to take a look at Sparkles :concurrency Sparkles

neon loom
#

Here we go

plain atlas
#

!pypi black

late dewBOT
#

The uncompromising code formatter.

Released on <t:1758241657:D>.

plain atlas
#

wow caching moment

neon loom
plain atlas
#

!pypi black

late dewBOT
#

The uncompromising code formatter.

Released on <t:1762739630:D>.

neon loom
plain atlas
#

ahhh

neon loom
#

I am happy how automated we've kept the release ❤️

plain atlas
#

yeah its super cool

neon loom
#

I'm too dumb to help with the parsing and ast and other code, so I helped with all the automation

plain atlas
#

what a mood

#

Every once in a while I swing in with a two line ci change 😆

neon loom
#

Every change helps

plain atlas
#

I've changed +14, -11 total lines of black and none of it in the package itself

neon loom
#

I've done very little last few years

plain atlas
#

yet I have 6 merged PRs!

neon loom
#

When I went pack to doing server and networky stuff, I didn't spend as much time in Python world

#

Been writing a lot of rust sadly ... one day I want a rust compiler for python syntax and that would be my dream language

plain atlas
#

hmmmmm

neon loom
#

Super statically typed compiled python

plain atlas
#

I think its time I write a bit more for the ci in black....

#

Right now partial releases are possible and that's suboptimal....

#

(one has not occurred, don't worry)

#

it should put them all together and then download them all in one final step, then upload

#

I can probably add release attestations as well

#

Just noticing wheels all get built again

neon loom
#

O yeah, that would be a nice safety thing to do

#

Feel free to add me as a reviewer when you do it

plain atlas
#

CI runs three times when making a release: the PR, the main branch, and the release published

#

huh...

neon loom
#

Yeah, that's been around since the dawn of time ...

#

GitHub fun fun ... I'm sure we could complicate our yaml for little benefit

#

I always looked at it as complexity vs. simplicity since it just burns CPU

plain atlas
#

We can totally overcomplicate the yaml!! I redid the ci on one of my projects and now i don't know how it works

neon loom
neon loom
#

You have to weigh up complexity vs. reward imo

plain atlas
#

In real state: I used nox and automatically construct the ci based on nox, which means I have full local ci inherently based on how the implementation works

neon loom
#

If you can't come back to it in 12 months and do it easily, that's a fail imo

#

I haven't pushed a black in 2 years and it was all fantastic today

#

Thanks to the work on our last release it seems reading recent history before releasing

plain atlas
neon loom
#

Maybe you should become /dev/urandom

plain atlas
#

TBH, would you be opposed to using nox for black? (if it solves a problem (the problem is using tox))

neon loom
#

😛

neon loom
plain atlas
#

I have no horse in black other than enjoying making CI PRs

neon loom
#

I wonder if it's time for us to manylinux_2_28 or what ever is the latest many linux standard, 2014 feels old old

plain atlas
#

if its backwards compatiable why upgrade?

neon loom
#

Would get a more modern binary I'd image that could perform better - But would have to benchmark

#

And work out which old ass platforms we break

#

glibc is at 2.42 and manylinux support 2.17+ - but no idea how fast it moves etc.

#

Someting I don't stay on top of

silent knoll
plain atlas
#

yeeee should do all or nothing releases

#

and attestation

silent knoll
plain atlas
#

something about that PR is off to me.

neon loom
plain atlas
#

I really hate it.

plain atlas
#

There is something wrong with the environment: configuration that scratches some "this introduces a security hole" itch

silent knoll
plain atlas
#

pypi size is all

#

you may have to ask for a limit at some point

#

which you'd get lol

neon loom
neon loom
plain atlas
#

ah nice

#

-# so by extension I'm one removed from all of the PyPI people :D

neon loom
#

https://pypi.org/stats/ - I added this years ago - shows all the largest artifact wise pypi packages

neon loom
neon loom
#

Fat rust static binaries

plain atlas
#

JUEKJW 56 GB??

#

uv beats numpy at this point wtf

#

and they don't even support android

#

pydantic is half the size.... wow

neon loom
#

It’s crazy cause this is ALL the releases on pypi. Numpy has been around a lot longer. But I think they truncate some old versions etc.

#

Use to be populated with lots of people doing nightly builds and uploading to pypi

plain atlas
#

yeah i remember back when charlie was releasing ruff multiple times per day

#

that was an intense time

neon loom
#

🐞🪲🦟 squashing

plain atlas
#

I remember that was a time where pypi seemed hesitant to grant the increase (at least from reading the public issue)

neon loom
#

Shit isn’t free

plain atlas
#

Yeah fr

#

charlie offered to earmark a donation but yeah....

#

it do be crazy what's happening over there

#

Did black ever get used to format parts of cpython?

flat krakenBOT
neon loom
plain atlas
#

well what I mean is that ruff format is used in a few places on cpython now 😔

#

it shoulda been black...

#

which it thankfully still is in a few places :D

neon loom
#

Wow. TIL. Surprised any of it got auto formatted

#

Lot of dislike and opinions across the cpython core team

flat krakenBOT
neon loom
#

Even with the black creator and who I used to sit next to as the cpython developer in residence (ambv) couldn’t get black formatted cpython

plain atlas
#

😔

#

we have ruff linted cpython tho so i guess not a total loss

#

i wonder if it was ever flake8

neon loom
#

Who decided / allowed ruff? Still in shock.

plain atlas
#

(I really gotta stop spending so much time on github, found it faster to load the blame by typing in the whole url)

flat krakenBOT
#

In the [wake][1] [of][2] [the][3] [rush][4] [to][5] [fix][6] [ci][7] [and][8] [builds][9] for [25.11.0][release] release (congrats btw!), I opened a quick fix PR to add support for a GitHub label which enables CI to build all wheels for a pull request.

As there is a staggering amount of wheels for an otherwise pure python project, Black prefers to not build all of the wheels for each pull request, but they are all built upon merge to main. This can ...

#

As of now, each individual wheel is pushed to PyPI seperately. This means if CI fails on whatever wheel when making a PyPI release, the release will be incomplete.

These should follow best practices and construct all of the wheels to artifacts, before downloading the whole bunch and pushing to pypi in one swoop.

Ideally, this should also be gated with docker publish (but not build) and any other release artifacts that are created, in order to make sure releases are fully atomic.

young sand
# neon loom Who decided / allowed ruff? Still in shock.

The only bits autoformatted in CPython are various internal tools in the Tools/ directory (these are also the only bits that are mypy-checked). Though we also run a very small selection of ruff lint rules on the code in Lib/test/; ruff's quite good at catching the classic error of accidentally redefining a test method in a unittest class, which leads to one of the two tests being "silently skipped".

There's currently no standardisation on whether ruff or black is used as the autoformatter; it's based mostly on the preference of the maintainer(s) for each subdirectory. There was a PR a while back that proposed using ruff everywhere, but it uncovered some bugs around formatting of match statements in ruff (which were actually fixed just last week https://github.com/astral-sh/ruff/issues/17796 ), so it didn't go anywhere

GitHub

Summary See this playground link, where I've put the expected formatting going in, and you can see the unexpected formatting coming out: https://play.ruff.rs/81f62f2d-6858-43eb-8a9b-67dcebdc56f...

plain atlas
#

the best thing an unformatted code base is good for imo

#

especially a massive one

#

is fuzzing of a formatter

#

pls never format cpython 🙏

plain atlas
plain atlas
# flat kraken

also hi i popped in again to mention i'm also avaliable on dc to discuss these two issues

late dewBOT
#

.github/workflows/mypy.yml lines 11 to 14

- "Lib/_colorize.py"
- "Lib/_pyrepl/**"
- "Lib/test/libregrtest/**"
- "Lib/tomllib/**"```
plain atlas
#

oh that's cool

#

tomllib is also one of the newest additions

#

and tbh one of the most mission critical outside of internals

#

well, from a user who uses 3.10 still and watches everything. use. tomli

drowsy jolt
young sand
#

Tomllib is also one of the ones that is mypy-checked in CI in its third-party backport, so mypy-checking both the upstream and downstream versions makes a lot of sense

drowsy jolt
#

yeah, the third-party backport being the original read + write library?

plain atlas
#

Ah yeah, string_processing is why I sometimes run black over my ruffed code (black smooths out the ruff edges 😆)

elder tusk
elder tusk
plain atlas
#

Oh damn

plain atlas
#

It took nine PRs to fix those two errors lmao

elder tusk
#

:hack-hack-hack: :typing-as-fast-as-we-can:

plain atlas
#

Oh.

#

It would be wise to check nothing in the test suite emits a removedinpytest9warning. Or maybe because it's 9 it already doesn't. Either way I remember pytest 8.2 breaking a plugin I used that silenced warnings

#

Though black is in really good hands for that it had two or three hands right there when a release needed to happen. Especially to fix CI without, casualty.

plain atlas
#

And now we know how to pin pytest if needed!

young sand
elder tusk
#

yeah, it actually made some stuff at work meaningfully faster

#

there are some legit users of mypyc out there, e.g. charset-normalizer, which is downloaded more than typing-extensions is

neon loom
#

mypyc is such a great concept. Have always tried to get work to POC writing a straight up compiler for strict typed python syntax to machine code.

mypyc is still generating c code right?

neon loom
drowsy jolt
#

there's a few things that have changed a bit, although I think they're still largely the same. that issue says they want to keep close parity:

  • Close parity with Black when migrating from Black to Ruff
  • Fix Ruff specific bugs
  • Innovate on local formatting (to keep close parity with black)
neon loom
#

Wow, that’s a long doc to say they want to stay close. 😳

#

I’ll read it later; too much for just awaking

plain atlas
neon loom
#

Do we want to is the first question.
I get URLs and some other things we shouldn’t split but I like comments conforming to line width

Main reason: vertical splitting files to work on multiple at once

dense jungle
plain atlas
#

You've called in woodruff, somehow

dense jungle
#

A lot of those deviations are things Black probably should do too, though

opal granite
# plain atlas astral moved some of its ci to a closed source bot recently so that's definitely...

Hi there, I’m the person who wrote the bot. We intend to open source it; there are two reasons it’s closed at the moment:

  1. it’s less than a week old, and I wrote it during a hackathon-style day, so it’s not really something we want to expose as a reference material for others until we’re more confident in its quality.
  2. The bot’s operations are part of an active security remediation effort around some weaknesses in Astral’s CI/CD, so we didn’t want to develop it in public (that would be outside of the norm for security issues disclosed to a project).

TL;DR: we’ll be making it public shortly, but I don’t think it’s unreasonable for it to have private for the reasons above.

plain atlas
#

That makes a lot of sense. Thanks for clearing that up!

opal granite
#

Also totally unrelated, but I’m one of the people who designed trusted publishing for PyPI. I see there’s that open PR for enabling it; I’m happy to answer any questions you all have about how it works/what the environment field does 🙂

neon loom
#

I just haven't spent the time to get up to speed

#

Will see if I get on top of work today and can spare an hour later today

plain atlas
toxic stormBOT
dense jungle
#

That would be nice though I feel trusted publishing is more important

#

Also what you suggest is not truly atomic, right? It just batches the wheel uploads together, so they happen closer in time. I seem to recall some proposal for truly atomic PyPI uploads but not sure that's been implemented yet.

plain atlas
#

Well yeah but see the latest comment on the trusted publishing pr: it's virtually the same fix for both

plain atlas
flat krakenBOT
#

Description

An example is not needed for --no-cache, since as a CLI flag its usage is obvious, and there's no different in output we could show with it. This also fixes it having an inconsistent style from the rest of the examples.

Checklist - did you ...

  • [N/A] Implement any code style changes under the --preview style, following the
    stability policy?
  • [N/A] Add an entry in CHANGES.md if necessary?
  • [N/A] Add / update tests if necessary?
  • [x] Add new / up...
elder tusk
# dense jungle A lot of those deviations are things Black probably should do too, though

i think the most common difference that gets discussed at work is that ruff never added support for some newer black formatting styles which are quite desirable like parentheses for conditional expressions, see e.g. https://github.com/astral-sh/ruff/issues/12856

GitHub

I was surprised that there's no existing issue for this. We decided not to implement the following Black 24 style changes: parenthesize_long_type_hints, wrap_long_dict_values_in_parens parenthe...

flat krakenBOT
#

Describe the bug

To Reproduce

For example, take this code:

[
    (1, 2),
    # # fmt: off
    # (3,
    #    4),
    # # fmt: on
    (5, 6),
]

And run it with these arguments:

$ black file.py

The resulting error is:

error: cannot format file.py: INTERNAL ERROR: Black 25.11.0 on Python (CPython) 3.11.13 produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be help...

flat krakenBOT
#

Description

Python 3.9 became end-of-life last month:

Compare https://github.com/psf/black/pull/4452 that dropped 3.8 in September 2024.

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [x] Add an entry in CHANGES.md if necessary?
  • [x] Add / update tests if necessary?
  • [x] Add new / update outdated documentation?
plain atlas
#

Hmmm

cyan hatch
#

anyone help me start with open surce

flat krakenBOT
flat krakenBOT
plain atlas
#

Looking into what needs to be done to split the wheel building and publishing as I'm working on a release workflow for a new project of mine.

#

there has to be a proper way to do this that does it right

#

as in: publishing the release should not trigger the ci to build everything. That has a risk with any single build failing and needing a re-release

flat krakenBOT
#

Describe the bug

As of black==25.11.0 but not in black==25.9.0, it's removing extra code comments.

To Reproduce

Run black a.py on the below:

# %% [markdown]

# fmt: off
# fmt: on

It overzealously removes the top comment, leaving just:

# fmt: off
# fmt: on

Expected behavior

black to not remove the header comments, as they're part of [Jupytext's percent format](https://jupytext.readthedocs.io/en/latest/formats-scripts.html#the-percent-fo...

late dewBOT
opal granite
# plain atlas Looking into what needs to be done to split the wheel building and publishing as...

The “normal” layout for this is to have everything in the same workflow, and have the build job(s) upload artifact(s) that the release job (which only runs on a tag or release trigger) then downloads. That way you get the same exact build steps running for both normal CI and releases, and re-running builds on failure isn’t a challenge (although IME it’s often easier to yank any partial state and re-do with a new patch anyways)

#

Another option would be a reusable workflow layout where build.yml (or whatever) is a reusable workflow that gets called by both the normal CI workflow and the release workflow

#

(But a larger nuance here is that, depending on how your builds work, sometimes you do want a release to fully trigger builds — conceptually release builds should be fully hermetic and not affected by e.g. CI caches, whereas for normal CI builds caching is ideal. But this of course makes things painful when a release build fails…)

plain atlas
opal granite
#

That’s why I usually recommend either having them be the same workflow (with different trigger sets) or reusable workflows (where publish would call build)

plain atlas
#

how can forks be kept from triggering it?

opal granite
#

PyCA Cryptography’s CI has an example of that for their release workflow

plain atlas
#

And I have to assume that workflow using workflow_run always runs in the default branch context?

#

eg it won't use a forked source with secrets

#

that's only pull_request_target

#

which is so dangerous that github finally changed it

opal granite
#

It has the exact same context as pull_request_target, ie it gets potentially triggered by a fork but starts from a “safe” head ref + access to the upstream’s secrets

plain atlas
#

so now pull_request_target will only be main/default branch

opal granite
plain atlas
#

ahhh

opal granite
#

“Context” is too overloaded 😅

flat krakenBOT
#

says that I need torch 2.9.1 becuase torchaudio 2.9.1 requires torch 2.9.1.

So uninstall 2.8.0 and install 2.9.1. Then I run

./ebook2audiobook.sh

And it uninstalls torch 2.8.0 and then uninstalls torch 2.9.1 then tells me I need torch 2.9.1 because torchaudio 2.9.1 requires torch 2.9.1.

And on and on and on.

Downloading torch-2.8.0-cp312-cp312-manylinux_2_28_x86_64.whl (887.9 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 887.9/887.9 MB 6.7 MB/s  0:02:18
Downloading nvidia_ncc...
flat krakenBOT
#

Fixes #4843

Black was incorrectly removing comments that precede # fmt: off/# fmt: on blocks, particularly affecting Jupytext's # %% [markdown] comments.

Description

Black 25.11.0 introduced a regression where comments before fmt:off blocks were removed. This broke Jupytext percent format files.

Example:

# Before:
# %% [markdown]
# fmt: off
# fmt: on

# After Black (broken):
# fmt: off  
# fmt: on

Root cause: Recent fmt:off/on changes d...

flat krakenBOT
silent knoll
#

just stumbled across https://pypi.org/project/straitjacket/, very interesting
unfortunately it was last updated with black 22.12b0, since mypyc compilation no longer allows it to monkeypatch black

flat krakenBOT
flat krakenBOT
#

This PR adds documentation explaining the behavior of the ci: build all wheels label.

Why this change is needed

The label exists to trigger a full wheel build on a PR, but GitHub Actions does not automatically rerun CI when a label is added.
This leads to confusion because contributors expect the wheel build to start immediately, but it only works after pushing a new commit.

What this PR adds

  • A new section in CONTRIBUTING.md describing:
    • the purpose of the `ci: bu...
flat krakenBOT
plain atlas
#

well that's AI generated smh

#

that pr description is entirely AI written.

flat krakenBOT
#
  • Fix BracketTracker.mark to ensure bracket_depth is set on all leaves, even when matching opening brackets are missing on the current line. This prevents an AttributeError in is_line_short_enough when processing lines containing only closing brackets.
  • Update src/black/comments.py and src/black/linegen.py to use _contains_fmt_directive instead of strict in checks for FMT_OFF/FMT_ON. This ensures that nested or complex comment blocks (like # # fmt: off) are correct...
plain atlas
#

The urge to add a section about AI to the contributing guidelines

young sand
silent knoll
#

except the people using ai are not the ones reading the guidelines

young sand
#

agreed, but it gives you something to link to when you close a PR

silent knoll
#

fair

young sand
#

saves you having to type out a long explanation each time 🙂

plain atlas
bright glacier
# young sand saves you having to type out a long explanation each time 🙂

I also have this github saved reply:

It is evident your contributions have developed with the assistance of LLM/AI tools. This in itself is not problematic, but we still expect you to review and adjust their output in line with the project expectations and requirements ([as per our contributing documentation](https://pip.pypa.io/en/latest/development/contributing/#submitting-pull-requests)). **Unfortunately, your contribution does not meet this bar.**

We do not have the resources to review and correct contributions that are filled with LLM errors and misunderstandings. If you are not already aware:

- LLMs often [hallucinate](https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence)), i.e. lie and make stuff up
- LLMs do not understand subtle context. While its output may be factually correct, it is likely that it is irrelevant/inapplicable to the exact situation because of unknown requirement, missing knowledge, etc.
- LLM generated texts are also generally hard/tiring to read. LLMs often generate _walls_ of text that are full of fluff and redundant statements. 

We understand that you may be using LLMs/AI as an aid for some some disability or barrier. You can use such tools as part of your work, but you are responsible for verifying their output and that they do not negatively impact everyone's ability to engage productively in the contribution process.

Thank you for your understanding.
azure plank
plain atlas
#

lmfao

flat krakenBOT
#

📝 Pull Request Description

Title

Fix: Preserve # %% [markdown] comments before # fmt: off (issue #4843)


Description of the Bug

  • Issue Reference: #4843
  • In Black 25.11.0, running the formatter on files containing Jupytext-style cell markers (# %% [markdown]) caused these comments to be removed unexpectedly.
  • This regression was not present in Black 25.9.0, meaning the bug was introduced between versions.
  • Specifically, when a...
azure plank
#

Might as well put that template to good use

silent knoll
#

again?

#

same guy

azure plank
#

yep

silent knoll
flat krakenBOT
#

📝 Pull Request Description

Title

Fix: Preserve # %% [markdown] comments before # fmt: off (issue #4843)


Description of the Bug

  • Issue Reference: #4843
  • In Black 25.11.0, running the formatter on files containing Jupytext-style cell markers (# %% [markdown]) caused these comments to be removed unexpectedly.
  • This regression was not present in Black 25.9.0, meaning the bug was introduced between versions.
  • Specifically, when a...
azure plank
#

... We might have to get someone to ban them from contributing to the PSF GitHub? I remember Jelle mentioning that last time we had AI spam

#

That's literally just the same changes in a new PR

azure plank
#

Maybe third time's the charm? Hopefully?

plain atlas
flat krakenBOT
#

Description

Fixes #3364
Fixes #4366
Closes #4822
Closes #4380

Implemented in the stable style without changing previosuly-formatted code.

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?
flat krakenBOT
#

Description

Fixes #4841
This error was caused by inconsistent detection of fmt: comments. This PR unifies it to use the contains_fmt_directive utility everywhere, fixing these edge cases. I also removed the underscore from the function name since it's now more widely used.

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [y] A...
flat krakenBOT
#

Add CI-related label documentation to issue triage guide

Description

This PR adds documentation for the ci: build all wheels label to the Issue Triage guide.

The new section explains:

what the label is used for

why GitHub Actions does not trigger CI automatically when the label is added

the requirement to push a new commit (even an empty one) to start the wheel build

security and resource reasons for not triggering builds on label events

that this label should only be ...

plain atlas
#

yeesh

#

I actually wanted to document that myself but was waiting for some maintainer to weigh in

#

I do not know if its worth documenting. I'm not sure it is.

#

@silent knoll

silent knoll
#

we have a page for issue triage where we document skip news so i think it makes sense

flat krakenBOT
flat krakenBOT
#

This PR enhances Black's syntax error reporting to provide clear, user-friendly error messages similar to Python's interpreter, addressing issue #4820.

🔗 Closes
Fixes 4820

🎯 Problem Solved
When Black encounters a Python file with a syntax error, the current error message is dense and confusing. The one-line format lacks visual clarity and doesn't provide enough context about where the error occurred.

Impact: Developers waste time deciphering cryptic error messages instead of quickl...

flat krakenBOT
#

Summary
This PR implements atomic PyPI releases by separating the build and publish phases. Previously, each wheel was uploaded to PyPI immediately after building, which could result in incomplete releases if any build failed mid-process. Now, all wheels are built first and stored as artifacts, then published to PyPI in a single atomic operation.

Problem
Fixes #4839

Current behavior:

Each wheel (sdist, pure wheel, and mypyc wheels) is pushed to PyPI immediately after building
If a...

flat krakenBOT
#

Description

Closes #4725

This PR removes unnecessary parentheses on the left-hand side of assignments. Black currently keeps parentheses around single targets and ordinary unpacking patterns, for example (b) = a()[0] or (c, *_) = a(), even though they don’t change the semantics and just add noise.

The update adjusts normalize_invisible_parens so these parentheses are only preserved when they actually matter. They’re still kept in cases involving:

  • a magic trailing comma t...
flat krakenBOT
flat krakenBOT
#

Description

  • Don't run docs workflow on non-docs changes
  • Don't run Fuzz workflow on only-docs changes
  • Run diff-shades compare & comment even if files failed
  • Remove ignored path now that we target 3.10
  • Format gallery/gallery.py
  • Remove code that targets 3.7
  • Document the removal of 3.9 runtime support

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an en...
flat krakenBOT
flat krakenBOT
#

Parsing automagic without running python kernel, cells with parseable syntax like ast.parse or IPython will be skipped

Description

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
#

Unit testing to fix the check automagic parser for syntax like ast.parse or IPython to be skipped

Description

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [ ] Add an entry in CHANGES.md if necessary?
  • [ ] Add / update tests if necessary?
  • [ ] Add new / update outdated documentation?
sterile cosmos
#

i use black in a python ide i made

#

but not gonna advertise it because rules

flat krakenBOT
#

Description

Closes #4731

Black was crashing with a parsing error when multiple # fmt: skip comments appeared in multi-part if-clauses. The crash occurred because when the second # fmt: skip was processed, its prev_sibling could include a STANDALONE_COMMENT node created by the first # fmt: skip. Since these synthetic nodes don't include trailing newlines (those are added later in the formatting pipeline), when the nodes were joined together via str(), they'd concatena...

flat krakenBOT
#

Describe the bug

black told me to report a bug:

~/.local/bin > black obsidian-preferences-please.py 
error: cannot format obsidian-preferences-please.py: INTERNAL ERROR: Black 25.11.0 on Python (CPython) 3.14.0 produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/6d/wgwms3kx2zx782p82r8x6qdw0000gn/T/blk_dv1novq0.log

Oh no! 💥 💔 💥
1 file failed to reformat.

To Reproduce...

flat krakenBOT
#

Description

Many noqa comments are no longer applicable, so I removed them. I also removed the C category, which only has the complexity check C901. It's the most ignored check by far, since there's rarely an obvious way to fix it, so it's typically just ignored. If it's preferred, I could add it back and try to decrease the complexity instead.

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    st...
flat krakenBOT
silent knoll
#
GitHub

Description

Fixes #4841
This error was caused by inconsistent detection of fmt: comments. This PR unifies it to use the contains_fmt_directive utility everywhere, fixing these edge cases. I also r...

GitHub

Description

Fixes #3364
Fixes #4366
Closes #4822
Closes #4380
Implemented in the stable style without changing previosuly-formatted code.
Checklist - did you ...

[-] Implement any code style cha...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

2023: #3407
2024: #4042
2025: #4522
Ruff: https://github.com/astral-sh/ruff/issues/20482

As always, the ideal is for all preview features to be stabilized, not including the unstable ones.


Ordered by most controversial to least:

multiline_string_handling (#1879)
Make expressions involving multiline strings more compact.

Input

textwrap.dedent(
    """\
    This is a
    multiline string
"""
)

MULTILINE = """
foobar
""".replace(
    "\n", ""
)

Output (off)
*unchang...

flat krakenBOT
#

Description

Docker builds are currently failing
https://github.com/psf/black/actions/runs/19766018487/job/56638900128
Not sure why they started failing, but this is my best guess at fixing it

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [-] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?
silent knoll
#

still failing

silent knoll
flat krakenBOT
flat krakenBOT
#

Description

Appears to fix the issue on my fork, but I had to modify the workflow to get it to run at all, so we'll see.
(thanks @hauntsaninja for noticing the new version!)

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [-] Add / update tests if necessary?
  • [-] Add new / update outdated documentation?
silent knoll
#

looks like that worked (it hasn't succeeded yet, but it takes 45 min to run normally, and it has been failing by now)

neon loom
#

Yeah the docker builds are super slow. I was impressed at how slow they are ...

Have never looked into trying to speed them up ...

flat krakenBOT
#

I am using the online formatter.

Describe the bug

black failed with two ignores for type checkers.

To Reproduce

import pandas as pd


interval_td = pd.Interval(
    pd.Timedelta("1 days"), pd.Timedelta("2 days"), closed="neither"
)


_td = (  # pyright: ignore[reportOperatorIssue,reportUnknownVariableType]
    interval_td
    - pd.Interval(  # type: ignore[operator]
        pd.Timedelta(1, "ns"), pd.Timedelta(2, "ns")
    )
)

And run it with the online playground.

...

real oxide
#

hello guys where do we talk of open source projects made with python in general?

flat krakenBOT
#

Description

Background info: On current stable, Black does not add nor remove parens around in clauses in comprehensions at all. wrap_comprehension_in standardized it to always add them if it would then fit in the line limit, and to remove them otherwise.

Resolves #4877

My approach was to always wrap the in clause if there's delimiters in it (not counting dots). This resulted in changes like this in Black's codebase, which I think are better?

I'm not sure if ...

silent knoll
#

i do think most of these changes look better, it's just more churn added so close to the 26.1 release, but it's honestly less than i thought it'd be (+84/-68 in shades)

dense jungle
#

the one with the sorted() calls definitely looks better with the new formatting though

flat krakenBOT
#

In https://github.com/psf/black/issues/4875#issuecomment-3593650163 while testing, I kind of felt like I didn't like wrap_long_dict_values_in_parens.

I get why wrap_long_dict_values_in_parens could make sense, and my feeling isn't the most principled feeling, which is why I didn't make an issue earlier. I think part of what I'm reacting to is seeing this in the aggregate, e.g. this would add literally tens of thousands of lines to the codebase I'm testing on.

This is a very long dict, b...

silent knoll
flat krakenBOT
#

(not a review of the code, just a review of the style)

Thanks for working on this!
I ran this on my work codebase and liked it there. I like the diff-shades on net too, but relatively more of those feels gratuitous.

Given that it does add more changes, it's late in the year, that there's something about adding parens here that feels a little new and different for Black (at least to me), and that the implementation is a little fiddlier, what do you say about the following:

  • We ship `w...
flat krakenBOT
#

Description

Closes #4730

Black was ignoring # fmt: skip in deeply nested expressions (e.g., multi-part if-clauses). This change updates the tree climbing logic to correctly find the start of the line and all relevant siblings, ensuring that # fmt: skip works as intended even in complex nested cases.

Checklist - did you ...

  • [x] Implement any code style changes under the --preview style, following the
    stability policy?
  • [x] Add an entry in CHANGES.md i...
flat krakenBOT
#

Description

Black is exploding the if guard in case patterns which have trailing commas in them, even if the guard expression fits in one line. The trailing comma logic should apply only to the case pattern, not the if guard.

Checklist - did you ...

  • [X] Implement any code style changes under the --preview style, following the
    stability policy?
  • [X] Add an entry in CHANGES.md if necessary?
  • [X] Add / update tests if necessary?
  • [X] Add new / update outdate...
flat krakenBOT
#

Description

Handled #4353 ticket. Added in implementation in various files to handle this issue including helper functions as well as actual changes.

Checklist - did you ...

  • [ ] Implement any code style changes under the --preview style, following the
    stability policy?
  • [Y ] Add an entry in CHANGES.md if necessary? Yes, I did add to changes.md
  • [Y ] Add / update tests if necessary? Yes, I added updated tests.
  • [ ] Add new / update outdated documenta...
flat krakenBOT
#

Description

Closes #4880

This PR fixes issue #4880 by ensuring that Black does not omit optional parentheses when doing so would merge a # type: ignore comment with other comments on the same line. Merging these comments causes Python's AST parser to lose the TypeIgnore node, resulting in AST equivalence failures and internal errors. The fix is minimal and surgical: it updates the logic in can_omit_invisible_parens() to detect and prevent this specific case. All existing ...

flat krakenBOT
flat krakenBOT
#

Description

  • Run scripts/release.py
  • Updated docs; git diff should be run before release.py because headings are removed

Checklist - did you ...

  • [-] Implement any code style changes under the --preview style, following the
    stability policy?
  • [-] Add an entry in CHANGES.md if necessary?
  • [-] Add / update tests if necessary?
  • [y] Add new / update outdated documentation?
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Reverts psf/black#4883

Sorry @Nikhil172913832, I missed a part of this that causes issues once I move this out of preview:

--no-preview-line-length-1 is meant to be a cop-out for known broken tests that were already broken when tests started being checked with --preview --line-length=1. It's meant to be used for newly-added tests.

Running with --line-length=1 is a good way to find stability issues. No test should crash when ran with it, because Black should never crash when run...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Please run Black on the codebase (ie python src/black .)

Some of the diff-shades changes look unideal, could you take a look at them? (click the "available in the logs" link)

Also, as a heads up, now that 25.12.0 has been released, and since we want to keep 26.1.0 limited to purely stabilizing preview styles as much as possible, this probably won't get merged until after 26.1 ships.

flat krakenBOT
#

This PR improves the documentation for how Black handles exclude patterns when
used with pre-commit. Since pre-commit passes file paths directly to Black,
Black's normal exclude rules do not apply unless --force-exclude is used.

The updated section explains:

  • why pre-commit's own exclude should be preferred,
  • how exclusions can be configured in pyproject.toml,
  • when --force-exclude is helpful as a fallback.
flat krakenBOT
#

This PR fixes Issue #3955.
When there are multiple string literals written next to each other (implicit string concatenation), Black currently leaves them as-is. In preview mode, this causes unstable formatting.

I added a small check in visit_atom() that detects when an atom has more than one string leaf, and then wraps the whole atom in parentheses. This makes the output more readable and consistent.

Example:
x = "hello" "world"

becomes:
x = (
"hello"
"world"
)

flat krakenBOT
#

Description

This hash-pins all GitHub Actions.

I used pinact run -v to perform and verify this; a separate tool like gha-update could be used to cross-check them for honesty!

Note: This only pins the actions; I haven't attempted any bumps. Dependabot will keep them updated, including updating the version comments.

For context: this is an important (but not final) step towards making GitHub Actions runs generally more hermetic/reproducible. One of the big issues with GitHub...

flat krakenBOT
flat krakenBOT
#

Description

Closes #4730

This PR addresses issue #4730, where # fmt: skip was being ignored or causing crashes in deeply nested expressions. The root cause is that Black's handling of fmt: skip converts AST nodes to string literals, which bypasses bracket tracking and can result in missing attributes like bracket_depth. This led to AttributeError exceptions, especially with extreme settings like --line-length=1.

Key changes:

  • Added `hasattr(leaf, "bracket_dep...
flat krakenBOT
neon loom
flat krakenBOT
#

Description

This follows #4901 with some more CI security improvements. Namely:

  • Where possible, the workflow-level default permissions have been fully dropped and job-level permissions are used to limit permissions to the smallest unit of work possible.
  • All actions/checkout usage now includes persist-credentials: false to avoid accidental credential persistence/leakage. Some exceptions to this that actually use the persisted credential (e.g. for git push) have `persist-cr...
flat krakenBOT
flat krakenBOT
#

Description

This follows #4901 and #4905 with some more small CI/CD security improvements. It hash-pins some of the dependencies added with #4611, minimizes more workflow/job permissions, and eliminates a few template injections (which probably aren't exploitable in practice in this context, but are still good to remove IMO!)

Following this, there's only one finding left from zizmor (which will unfortunately be nontrivial to fix, since it involves a workflow_run trigger). I'm happ...

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Description

This Pull Request addresses Issue #3083 by updating the documentation to mention third-party tools that can be used to format code examples embedded in docstrings (doctests).

Since Black does not format doctests by default, this documentation clarifies for users how to achieve consistent formatting across their entire project.

I have added a new section, "Formatting Doctests," to docs/usage_and_configuration/the_basics.md, recommending the use of the `blacken-do...

flat krakenBOT
#

Description

This Pull Request addresses Issue #3015 by clarifying the correct file exclusion mechanism when using Black as a pre-commit hook.

The core problem is that the Pre-commit framework passes file paths explicitly to the Black CLI, which causes Black's standard --exclude option to be ignored.

The solution is to guide users to use the Black-specific --force-exclude option in their pyproject.toml file to ensure files are properly skipped.

The documentation was...

flat krakenBOT
#

Description

This adds a new workflow, zizmor.yml, which will run zizmor via zizmor-action on each push and pull request.

See #4901, #4905, #4906 for motivating context.

Note: this adds a new workflow for zizmor, but another option here would be to integrate zizmor via pre-commit. The upside to that is that running it locally would be constant with CI; the downside is that it's not easy (possible?) to directly integrate with GitHub's SARIF consumption support for stateful fi...

flat krakenBOT
flat krakenBOT
#

Describe the bug

If you:

  • have string processing enabled
  • have a line that has a string literal exceeding line-length, followed by a trailing comma (to make it a one-item tuple)
  • the line is NOT assigned to a variable

...then black will error.

To Reproduce

Run this code in bash:

echo '"A long string literal that is not assigned to a variable, exceeds line length when string-processing is enabled, and has a trailing comma (to make it a one-item tuple)",' | black --preview...
flat krakenBOT
flat krakenBOT
#

Description

Addresses issue #3083. Adds a documentation page under integration for tools that can apply Black formatting to doctests. This is meant to inform users of 3rd party tools that cover functionality not covered by Black. New doc page includes a brief description of blackdoc and blacken-docs. The integrations index page was also updated to list this new page.

Checklist - did you ....

flat krakenBOT
#

Description

Fix crash in string-processing preview for unassigned one-item tuples of string literals with a trailing comma.

  • Problem: Black crashed when formatting code like:
"A very long string that exceeds line length and has a trailing comma",

because it tried to split the string but did not wrap it in parentheses, producing code that is not AST-equivalent.

  • Cause: _prefer_paren_wrap_match() decides whether to wrap a literal in parentheses...
flat krakenBOT
#

Description

This PR replaces the current power operator hugging implementation, which uses transformers and is quite complicated, with a simpler one, implemented directly in the whitespace function.

The original implementation was created in #2726 and later fixed in #2806, #2874, #3942, #4154. Currently it takes around 150 lines of code, while the new implementation takes around 30 lines.

A minor side-effect of the change is that the whitespace is removed also if the power ...

flat krakenBOT
#

Description

In a nutshell, this PR turns foo(bar=x + y), where the spacing looks confusing/illogical, into foo(bar=(x + y)).

The general idea is to make whitespace consistent with operator precedence - it is similar in spirit to #157 or #646.

See this short discussion for more details. A few developers agreed that the current formatting is "a little awkward" or would...

silent knoll
flat krakenBOT
flat krakenBOT
#

Description

Various unrelated refactors, most of which are too small for their own PR

  • 713692c: Rename workflows, jobs, and steps for consistency, clarity, and correctness
  • 406fba3: Set up dependency groups in pyproject.toml
    • Use them most places (some places are migrated in future commits)
    • Also bumps some action runner versions
    • And updates dependabot/pre-commit config to check for more updates
  • 5102f81: Refactor diff-shades workflow
    • No long...
flat krakenBOT
#

Description

This PR fixes issue #4912 where string_processing would crash with an INTERNAL ERROR
when processing an unassigned long string literal with a trailing comma (creating a
one-item tuple).

The Problem: When a line contains only a long string literal followed by a trailing
comma (making it a one-item tuple) and is not inside brackets, StringSplitter would
split the string into multiple implicitly concatenated strings. This created multiple
expressions where on...

flat krakenBOT
#

In frozen (PyInstaller) builds, disable multiprocessing by limiting workers to 1. This
prevents shutdown errors caused by worker processes attempting to import modules after
PyInstaller cleanup begins.

Fixes #4823

Description

When using the prebuilt Black binary on macOS (built with PyInstaller), users encounter
a FileNotFoundError for base_library.zip during shutdown. This happens because
ProcessPoolExecutor worker processes attempt to import modules after PyInstaller ...

flat krakenBOT
flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Is your feature request related to a problem? Please describe.

Hi, I'm the author of pathspec, and recently released v1. The biggest change is GitWildMatchPattern (a.k.a. "gitwildmatch") was split into two different implementations. (1) GitIgnoreBasicPattern (a.k.a. "gitignore") is new and properly implements the patterns in gitignore's documentation. (2) GitIgnoreSpecPattern is the previous *GitWil...

flat krakenBOT
#

Describe the bug

When my code contains a multi-line expression that's concatenated using backslash (\) and no indentation, black cannot parse my code

To Reproduce

For example, take this code:

if True:
    foo = 1+\
2
    print(foo)

And run it with these arguments:

$ black file.py --target-version py313

The resulting error is:

error: cannot format file.py: Cannot parse for target version Python 3.13: 3:0: 2

Expected behavior

The file shou...

flat krakenBOT
#

Summary

Request to add MCP (Model Context Protocol) integration for AI-powered Python development.

What is MCP?

Model Context Protocol is Anthropic's open standard for AI-tool integration.

Proposed Features

  • AI-assisted code development
  • Natural language package management
  • Intelligent linting and formatting
  • Automated documentation

Implementation Reference

I've built 9 production MCP servers:

silent knoll
dense jungle
#

Maybe (1) for compatibility?

#

The message isn't clear about the difference between (1) and (3) though