-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Indicate that a final newline was added in --diff #1897
Indicate that a final newline was added in --diff #1897
Conversation
--diff
Now that I know it's an existing Python bug (I didn't think to look until after I posted the PR), I could reword this as a workaround for that bug, if that's valuable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes themselves look great and testing locally they do work so +1 from me!
Besides my review comment, please add an entry in CHANGES.md
so the person verifying and updating the changelog before a new release has less work to do :) And I guess while you're at it, why not add yourself to the authors list in the README?
Also while this isn't a blocker, I can't reproduce the bug where Black doesn't add a newline using the VS Code integration on my machine interestingly 😕 Maybe the fact I'm using Visual Studio Code version 1.52.1 or version v2020.12.424452561 of the Python extension is why? I honestly don't care that much since theoretically this should fix the bug, but from experience even seemingly well tested PRs can have undetected serious holes ...
Thanks for looking into this and submitting a patch anyway! You rock!
Would it be useful to mention CHANGES.md in CONTRIBUTING.md? I wasn't aware I was supposed to add to the former, based only on reading the latter. (And based on the PR I modelled from, #1328.) |
@ichard26 Should CHANGES.md link to the PR or the issue? |
Yeah it would definitely help! I have other ideas to deal this issue (hi towncrier), but having a reminder in the docs can't hurt!
Honestly I'm not sure of what the actual recommendation is, but I would go with linking to the issue personally even though the status quo is to link to the PR. For non-bugfix PRs though, linking to PR would probably be better(?) |
@ichard26 On the repro in VS Code, it's possible VS Code's general editor setting for "add missing newline" is set, which will be operating after |
Sorry for the wild batch of force-pushes. I got excited and overlooked a couple of requested changes. -_- It should be all-good now, the only changes since the last review were textual |
I checked if I had that option set and I'm pretty sure I didn't. When I purposely installed an immediately crashing version of Black, no newline was added still. But it's probably some misconfiguration or misunderstanding on my part, anyway 95% of time I use Vim. Does this patch for you work on your Visual Studio Code setup? If yes, I'll just go with that then :-) edit:
eh, not even close in badness to me unintentionally making it impossible to properly setup a development environment for Black development ... whoops .... So yeah, don't worry about it! |
I can reproduce the problem with released Black and Python extension ms-python.python-2020.12.424452561, under VSCode 1.52.1, after I remove And using the black.exe built from this PR, the problem is fixed. |
Looking at this again, somethings are sticking out to me, I'mma do another review hopefully soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey this almost looks good to go, but on a second pass, something doesn't seem right. Not a big deal, just something odd I noticed.
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @cooperlees @JelleZijlstra this should be ready to go, a final review and eventual merge would be appreciated! Thanks in advance!
Master build failed on Documentation build but I can't see how it relates to my changes.
|
That code looks more like it's related to the parser driver requiring newline-terminated text, which I think is probably part of the API contract. |
Fixes: #1662
This works around bpo2142 from 2008.