Skip to content
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

Fix unstable format involving backslash + whitespace at beginning of file #948

Merged
merged 3 commits into from
Aug 4, 2019

Conversation

Jma353
Copy link
Contributor

@Jma353 Jma353 commented Jul 28, 2019

This PR fixes #922 - an unstable sort involve Python line continuation with \. The issue describes the problem pretty well.

To my knowledge, there should be no situation where Black outputs a file formatted with empty lines at the beginning. By performing this check in the format function, we fix the above issue.

NOTE: Open to feedback on this solution, threw it together pretty quickly after doing some basic debugging of how Black parses lines and whatnot. Open to feedback on it. Also, I'm pretty sure it doesn't break any invariants of the formatter, but would like feedback on that as well.

black.py Outdated Show resolved Hide resolved
@Jma353
Copy link
Contributor Author

Jma353 commented Aug 3, 2019

Moved the check to EmptyLineTracker @zsol, this should be good for another review.

@zsol
Copy link
Collaborator

zsol commented Aug 4, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Black produced different code on the second pass of the formatter: Explicit line join in the first line
2 participants