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 No blank line after if/for/while/def #1180

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ashmichheda
Copy link

This PR fixes #1091

yapftests/main_test.py Outdated Show resolved Hide resolved
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))
Copy link
Member

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.

Copy link
Author

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.

Copy link
Author

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.

@EeyoreLee
Copy link
Contributor

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

@Spitfire1900
Copy link
Contributor

Please add a new knob + appropriate tests

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.

No blank line after if/for/while/def, etc.
4 participants