Comments (4)
@j-kleemann - Thanks! The addition commit is great! I'll merge it but release maybe tomorrow.
from vscode-extension-yapf.
@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 black[jupyter]
, similar as jupyter magic function, so I do that on the extension side. Do you think it will be better if I always remove the empty line at the end in jupyter. Or do you have some situation that need the empty line at the end. There are already quite a few knobs here, so I want to try not to add extra new knob setting.
from vscode-extension-yapf.
@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.
from vscode-extension-yapf.
@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!
While I am already happy with your solution, I still have one improvement idea:
Right now your code does not detect lines containing only whitespaces as blank, e.g, when formating
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).
I added a rstrip(" \t")
to your blank-line-detection code in PR #56, so it should now also consider lines containing only spaces and tabs as blank as well and keep a new line there (the tabs and spaces will be gone though, because yapf will remove them, but this should be fine and more often desired than not).
from vscode-extension-yapf.
Related Issues (20)
- Path to .style.yapf HOT 5
- Yapf formatter with devcontainers not sticking HOT 3
- Range Formatting HOT 6
- Python 3.7 is not supported HOT 2
- Formatting will be break for jupyter on `FormatOnType` mode if there are some magic function
- The "yapf" extension is configured to format programs, but not "Python"-files. HOT 6
- Cannot start server HOT 3
- Cannot handle new 3.12 f-strings, hangs up completely HOT 6
- Formatter is constantly formatting HOT 5
- The new version format: {year}.{month}.1{day}{hour}{minute}{second} HOT 1
- Yapf formatting on type instead of on save HOT 4
- Keep getting the message "there is no formatter for 'python' files installed" HOT 3
- SyntaxError for a Python 3.7 conda environment HOT 4
- yapf: input filenames did not match any python files - No formatting done. HOT 2
- Format Selection is formatting the entire file HOT 5
- "ALLOW_MULTILINE_DICTIONARY_KEYS" flag no longer working HOT 1
- Something has gone awry with extension installed on Remote HOT 1
- [Feature Request] I hope to add a command to generate a yapf configuration file. HOT 1
- Newline is added to empty files causing PEP8 warning W391 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-extension-yapf.