Skip to content

Add newlines before comments in E305#12606

Merged
charliermarsh merged 1 commit intomainfrom
charlie/nl
Aug 1, 2024
Merged

Add newlines before comments in E305#12606
charliermarsh merged 1 commit intomainfrom
charlie/nl

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
@github-actions
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
@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