Describe the bug
For files with a #fmt:off blocks, black will still remove empty newlines in these otherwise-unformatted sections. This is kind of pedantic, but it defies expectations that black would change anything at all here.
To Reproduce
Given the source file (note especially the trailing newlines at the end):
something = [1,2,3]
# fmt:off
other = [1,2,3
]
# fmt:on
another = [1,2,3]
# fmt:off
last = [1,2,3
]
And run it with these arguments:
$ black --diff foo.py
--- foo.py 2022-02-10 21:51:33.647821 +0000
+++ foo.py 2022-02-10 21:54:13.748438 +0000
@@ -1,19 +1,15 @@
-something = [1,2,3]
+something = [1, 2, 3]
# fmt:off
other = [1,2,3
]
-
# fmt:on
-another = [1,2,3]
-
+another = [1, 2, 3]
# fmt:off
last = [1,2,3
]
-
-
would reformat foo.py
All done! ✨ 🍰 ✨
1 file would be reformatted.
Expected behavior
Black should leave everything as-is inside #fmt:off blocks, including whitespace and newlines.
Environment
(venv39) jreese@butterfree ~/scratch » black --version
black.macos, version 21.4b2
- OS and Python version: macOS 12.1, Python 3.9.3
Describe the bug
For files with a
#fmt:offblocks, black will still remove empty newlines in these otherwise-unformatted sections. This is kind of pedantic, but it defies expectations that black would change anything at all here.To Reproduce
Given the source file (note especially the trailing newlines at the end):
And run it with these arguments:
Expected behavior
Black should leave everything as-is inside
#fmt:offblocks, including whitespace and newlines.Environment