You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to configure Ruff so that it ensures one empty newline at the end of each file in Python. This should be W292 (missing-newline-at-end-of-file), and is implemented in preview mode (so my understanding goes from #2402). My current pyproject.toml is below.
And then running ruff check . (even with --isolated) yields, "All checks passed!". I double-checked, and wc -l gives me 1 line in main.py. I am using Ruff 0.3.4, installed via pip, on macOS Sonoma 14.4.1.
The text was updated successfully, but these errors were encountered:
I believe echo does write a newline by default. With echo -n, the rule is working as intended in my testing:
ruff on main [$] is 📦 v0.3.4 via 🐍 v3.11.8 via 🦀 v1.77.0
❯ echo -n "print('Hello World!')" >> main.py
ruff on main [$?] is 📦 v0.3.4 via 🐍 v3.11.8 via 🦀 v1.77.0
❯ wc -l main.py
0 main.py
ruff on main [$?] is 📦 v0.3.4 via 🐍 v3.11.8 via 🦀 v1.77.0
❯ cargo run check main.py --select W --preview -n
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/ruff check main.py --select W --preview -n`
main.py:1:22: W292 [*] No newline at end of file
|
1 | print('Hello World!')
| W292
|
= help: Add trailing newline
Found 1 error.
[*] 1 fixable with the `--fix` option.
Oh god, apparently I'm just dumb. I didn't realize wc -l counted newline characters (and in your case, wc -l prints 0). In my actual project, it turns out neovim just didn't show line numbers for the empty newline at the end, so I was incredibly confused. Sorry about that, I'll close this issue.
I want to configure Ruff so that it ensures one empty newline at the end of each file in Python. This should be
W292
(missing-newline-at-end-of-file
), and is implemented in preview mode (so my understanding goes from #2402). My currentpyproject.toml
is below.A MWE is fairly straightforward:
And then running
ruff check .
(even with--isolated
) yields, "All checks passed!". I double-checked, andwc -l
gives me 1 line inmain.py
. I am using Ruff 0.3.4, installed via pip, on macOS Sonoma 14.4.1.The text was updated successfully, but these errors were encountered: