-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[pycodestyle
] Handle each cell separately for too-many-newlines-at-end-of-file
(W391
)
#15308
Conversation
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). |
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
W391 | 19 | 2 | 17 | 0 | 0 |
.../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
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. |
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.
Thanks
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