[pycodestyle] Handle each cell separately for too-many-newlines-at-end-of-file (W391)#15308
Merged
dylwil3 merged 6 commits intoastral-sh:mainfrom Jan 9, 2025
Merged
[pycodestyle] Handle each cell separately for too-many-newlines-at-end-of-file (W391)#15308dylwil3 merged 6 commits intoastral-sh:mainfrom
pycodestyle] Handle each cell separately for too-many-newlines-at-end-of-file (W391)#15308dylwil3 merged 6 commits intoastral-sh:mainfrom
Conversation
Collaborator
Author
|
One aesthetic question is whether internal cells should still be allowed to have a single trailing newline (at the moment this is what the fix produces/allows). |
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| W391 | 19 | 2 | 17 | 0 | 0 |
MichaReiser
reviewed
Jan 7, 2025
.../pycodestyle/snapshots/ruff_linter__rules__pycodestyle__tests__preview__W391_W391.ipynb.snap
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pycodestyle/rules/too_many_newlines_at_end_of_file.rs
Outdated
Show resolved
Hide resolved
Member
I think we should and doing so would be consistent with the formatter. It would be very annoying if you write a cell with a newline at the end, hit save and Ruff fixes away the newline before you had a chance to write the next content. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jupyter notebooks are converted into source files by joining with newlines, which confuses the check too-many-newlines-at-end-of-file (W391). This PR introduces logic to apply the check cell-wise (and, in particular, correctly handles empty cells.)
Closes #13763