New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"--diff" option doesn't add a newline at the end of the file using 20.8b1 #1662
Comments
Just dropping by to add some information (I honestly have no idea why this was changed and how to make everyone happy):
|
Looking at #526, it seems to me that the diff format being generated for "add a final newline" was incorrect (it was somehow counting the final 0-byte additional line) but the applied solution just hid the problem by dropping the added newline entirely, invalidating the output of The correct format (per the Diffutils docs) is that an incomplete line is followed by a line starting with
The fix should be as simple as making the call to Sadly,
That value needs to be
So as well as making it That should make Edit: I took a couple of hours and implemented the above in #1897, and now I get output identical to Edit2: I just thought to look, and this is a known issue with |
Fixes: #1662 Work-around for https://bugs.python.org/issue2142 The test has to slightly mess with its input data, because the utility functions default to ensuring the test data has a final newline, which defeats the point of the test. Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Describe the bug
Running
black --diff
on a file without an ending newline will not add it to the diff when using 20.8b1.To Reproduce Steps to reproduce the behavior:
black --diff myfile.py
Expected behavior
For
black --diff
to add a newline at the end of the file in the diff, which was the behaviour in 19.10b0:Environment (please complete the following information):
Does this bug also happen on master?
This also happens on black, version 20.8b2.dev10+g1d2d726.
Additional context
Running
black myfile.py
correctly without--diff
adds a newline at the end of the file.The text was updated successfully, but these errors were encountered: