-
Notifications
You must be signed in to change notification settings - Fork 5
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
Trailing empty line added to end of file / notebook cell #52
Comments
@j-kleemann - yup, cause yapf will always add a empty line at then end and I just invoke it. The problem is yapf hasn't provide a release to format jupyter like |
@j-kleemann - hi, I create a PR that if your cell end with a empty line, it will hold on it and if your cell didn't has a empty line at the end, I will remove the empty line at the end. If it can fix your situation, I'll merge it later. |
@EeyoreLee - Wow that was quick! Thank you, I think your solution of keeping an existing blank line, while removing it if it hasn't been there before is ideal, way better and more flexible than any configuration switch! def f():
pass # The next line seems empty, but it has four spaces.
it will remove the empty line at the end, which some people might not want (I actually realized that it can be quite useful to have the newline stay at the end, while one is still working on the cell 😅 and regularly you will have such whitespace-only lines because you hit enter on the previous line and vs code already intended the new line for you). |
@j-kleemann - Thanks! The addition commit is great! I'll merge it but release maybe tomorrow. |
If a file or a notebook cell is formatted it will cause the last line to be an empty line.
While for files this might be desireable, in a Jupyter Notebook I personally find it irritating, as there, cells often are only a few lines long anyway and the additional empty lines at the end of the cells now add up fast (and cause a lot of changes for git).
When I used yapf previously with the built-in support via the
"python.formatting.provider" : "yapf"
setting this was not the case and I don't think this is a yapf setting either (couldn't find anything, and I had the same style setting before with the old built-in support, when I didn't have this issue, and now the same behaviour even if I use the default style...)?Is there any way to make this configurable or supress adding a trailing empty line in notebook cells?
Thanks!
yapf extension version: 0.1.9
yapf python package version: 0.40.2
VS Code Version:
Version: 1.83.1 (user setup)
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:48:05.904Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
The text was updated successfully, but these errors were encountered: