-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
T: bugSomething isn't workingSomething isn't working
Description
Describe the bug
error: cannot format foo.py: INTERNAL ERROR: Black 25.1.1.dev56+gb3ae57b on Python (CPython) 3.13.5 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 helpful: /tmp/blk_kir8cfms.log
To Reproduce
Minimal repro:
def foo():
possibly_redundant_lowlevel_checkpoints: list[ # pyright: ignore[reportUnknownVariableType]
cst.BaseExpression
] = field( default_factory=list)
the generated logdiff:
Mode(target_versions=set(), line_length=88, string_normalization=True, is_pyi=False, is_ipynb=False, skip_source_first_line=False, magic_trailing_comma=True, python_cell_magics=set(), preview=False, unstable=False, enabled_features=set())
--- source
+++ first pass
@@ -1,4 +1,4 @@
def foo():
- possibly_redundant_lowlevel_checkpoints: list[ # pyright: ignore[reportUnknownVariableType]
+ possibly_redundant_lowlevel_checkpoints: list[
cst.BaseExpression
- ] = field( default_factory=list)
+ ] = field(default_factory=list) # pyright: ignore[reportUnknownVariableType]
--- first pass
+++ second pass
@@ -1,4 +1,4 @@
def foo():
- possibly_redundant_lowlevel_checkpoints: list[
- cst.BaseExpression
- ] = field(default_factory=list) # pyright: ignore[reportUnknownVariableType]
+ possibly_redundant_lowlevel_checkpoints: list[cst.BaseExpression] = field(
+ default_factory=list
+ ) # pyright: ignore[reportUnknownVariableType]
I managed to further minify it to
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[ # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
int
] = []
where the long line is now 89 characters long. And the logdiff gives
Mode(target_versions=set(), line_length=88, string_normalization=True, is_pyi=False, is_ipynb=False, skip_source_first_line=False, magic_trailing_comma=True, python_cell_magics=set(), preview=False, unstable=False, enabled_features=set())
--- source
+++ first pass
@@ -1,3 +1,3 @@
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[ # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[
int
-] = []
+] = [] # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
--- first pass
+++ second pass
@@ -1,3 +1,3 @@
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[
- int
-] = [] # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: list[int] = (
+ []
+) # bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Environment
Tested with latest release, installing from git and the online formatter - all of them fail:
black --version
black, 25.1.1.dev56+gb3ae57b (compiled: no)
Python (CPython) 3.13.5
This is newly written code, so I don't know if it can be bisected.
Metadata
Metadata
Assignees
Labels
T: bugSomething isn't workingSomething isn't working