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

Add newlines before comments in E305 #12606

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Add newlines before comments in E305 #12606

merged 1 commit into from
Aug 1, 2024

Conversation

charliermarsh
Copy link
Member

Summary

There's still a problem here. Given:

class Class():
    pass

    # comment

    # another comment
a = 1

We only add one newline before a = 1 on the first pass, because max_precedling_blank_lines is 1... We then add the second newline on the second pass, so it ends up in the right state, but the logic is clearly wonky.

Closes #11508.

@charliermarsh charliermarsh added the bug Something isn't working label Aug 1, 2024
Copy link
Contributor

github-actions bot commented Aug 1, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh charliermarsh merged commit a3e67ab into main Aug 1, 2024
20 checks passed
@charliermarsh charliermarsh deleted the charlie/nl branch August 1, 2024 03:11
@kaddkaka
Copy link

kaddkaka commented Aug 1, 2024

Are comments always tied to the next code line independent of indentation? Or does the indentation of a comment control where the empty lines are inserted?

@charliermarsh
Copy link
Member Author

Should be the latter (controlled by indentation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ruff check fix E305 "blank-lines-after-function-or-class" adds incorrectly placed newlines.
2 participants