You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Hello, I believe I have found a bug in how black handles
fmt: skip
. Consider the following snippet: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:But this snippet is reformatted by black to:
To prevent formatting of first dictionary, I have to add
fmt: skip
to both dictionaries:or surround the first dictionary with
fmt: off
-fmt:on
:I'm using the following version, installed with pipx on Debian Trixie (current testing):
The text was updated successfully, but these errors were encountered: