W391 blank line at end of file что значит
Comments
ghost commented Dec 31, 2014
Seems like a contradiction, fixing W391 introduces W292
Maybe there is an issue with the way I resolved W391
The text was updated successfully, but these errors were encountered:
sigmavirus24 commented Dec 31, 2014
A newline at the end of a file does not mean that there needs to be an empty line. Your editor may not show this to you but the raw bytes would look like:
If you don’t have the last \n there then you will see W391. You seem to be doing
Edited to fix the last example.
IanLee1521 commented Jan 3, 2015
Could you provide some sample code where this is an issue? Thanks.
jkterry1 commented Mar 15, 2018
Hey, I seem to be having this issue as well, with this sample code:
FichteFoll commented Mar 15, 2018 •
Since this error is highly whitespace-sensitive, I don’t think it can be reproduced with simple code blocks as those are stripped. Please upload files.
That said, I suspect that the initial problem was that the end of the file looked as follows:
Note that the last line here is not empty but has 4 spaces. This should raise W391. It was then attempted to fix the error by removing the last newline, but that left the four spaces in the now last line, which caused W292 to be raised.
hoylemd commented Mar 16, 2018 •
As a workaround in the meantime, I have a bit in my editor(vim) config(.vimrc) that strips trailing whitespace whenever a buffer is saved. That might help you (@justinkterry) in the short term, if you use vim and are ok with your editor cleaning whitespace up for you:
bsmoliak commented Jan 4, 2019
W391 appears to supercede W292.
Seems like W292 should be raised first.
codypiersall commented Jan 16, 2019
Hmmm, for what it’s worth, it seems like Vim inserts the newline at the end of the file, but it doesn’t look like there is a newline. I wonder if this is what was happening with the OP?
kierun commented Mar 7, 2019
This is the file I use:
The last line does have a [W292] warning on it. Flake8 passes fine.
Running hexdump, get:
This is what I see on screen:
OS: Centos (7.6.1810), neovim (0.3.2), and neovim-qt (master)…
FichteFoll commented Mar 7, 2019
What happens when you run pycodestyle sanitise.py from the command line? This could be a problem in the vim intergation.
kierun commented Mar 7, 2019
What happens when you run pycodestyle sanitise.py from the command line? This could be a problem in the vim intergation.