-
Notifications
You must be signed in to change notification settings - Fork 895
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 No blank line after if/for/while/def #1180
base: main
Are you sure you want to change the base?
Conversation
yapf/__init__.py
Outdated
@@ -108,6 +108,8 @@ def main(argv): | |||
|
|||
source = [line.rstrip() for line in original_source] | |||
source[0] = _removeBOM(source[0]) | |||
# filter all the tuples with empty space | |||
source = list(filter(None, source)) |
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.
I don't like this change, as it seems overly broad. For instance, if there are disabled sections, we don't want to remove the newlines from them.
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.
ok, thanks! Yeah, makes sense to not format the disabled sections. I'll try to see if I can prevent the commented section from filtering.
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.
@bwendling, I have added a util function that filters out the comment sections while removing the new lines. Kindly let me know for any feedback.
Some blank line is uesd to make code more readable. It shouldn't be so decisive to remove all blank. This issue just wanna remove the black at the begining of a code block. Please at least add a knob if you have a plan to merge the feature that remove other blank lines. @bwendling |
Please add a new knob + appropriate tests |
This PR fixes #1091