-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: fmtskipfmt: skip implementationfmt: skip implementationT: bugSomething isn't workingSomething isn't working
Description
Hello, I believe I have found a bug in how black handles fmt: skip. Consider the following snippet:
t = (
{"foo": "very long string", "bar": "another very long string", "baz": "we should run out of space by now"},
{"foo": "bar"},
)Without any changes, the line with first dictionary is 114 characters long and should be reformatted by black, which has a default line length limit set to 88 characters.. Second line is only 18 characters long and should be left intact.
Now, if I wanted to preserve formatting in this snippet, I believe I should add fmt: skip after the first dictionary:
t = (
{"foo": "very long string", "bar": "another very long string", "baz": "we should run out of space by now"}, # fmt: skip
{"foo": "bar"},
)But this snippet is reformatted by black to:
t = (
{
"foo": "very long string",
"bar": "another very long string",
"baz": "we should run out of space by now",
}, # fmt: skip
{"foo": "bar"},
)To prevent formatting of first dictionary, I have to add fmt: skip to both dictionaries:
t = (
{"foo": "very long string", "bar": "another very long string", "baz": "we should run out of space by now"}, # fmt: skip
{"foo": "bar"}, # fmt: skip
)or surround the first dictionary with fmt: off - fmt:on:
t = (
# fmt: off
{"foo": "very long string", "bar": "another very long string", "baz": "we should run out of space by now"},
# fmt: on
{"foo": "bar"},
)I'm using the following version, installed with pipx on Debian Trixie (current testing):
$ black --version
black, 24.4.2 (compiled: yes)
Python (CPython) 3.11.9
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
F: fmtskipfmt: skip implementationfmt: skip implementationT: bugSomething isn't workingSomething isn't working