Comments (16)
You can type o command to start new line after you go to the end of file
from pycodestyle.
pep8.py correctly detects '\n\n' at end of file with warning W391.
It does not find any error if the file ends with '\n' only.
I don't see any misbehaviour here.
from pycodestyle.
I've installed pep8 0.7.0 from PyPI.
Then I did:
$ echo -en '\n' > /tmp/test.py
$ pep8 /tmp/test.py
/tmp/test.py:1:1: W391 blank line at end of file
So pep8 from PyPI still has this problem
from pycodestyle.
You did not do the right test.
echo -en 'a\n' > /tmp/test.py
pep8.py /tmp/test.py
from pycodestyle.
Right. So I close the issue.
from pycodestyle.
PEP8 doesn't require that files are ending with blank lines - http://www.python.org/dev/peps/pep-0008/
Actually it is convenient to have \n\n at the end of file at least in Vim, and not \n\n\n.
from pycodestyle.
Yes, Vim treats \n as end of line, not as carriage return like in many editors. So I may type one symbol less - less typing - less work :-)
from pycodestyle.
Actually it is more typing, because without \n\n in Vim you can not just go to the end of file an press enter. You enter will at the start of the last line. It suxx that PEP8 validator forces everybody to this annoyance.
from pycodestyle.
Yes, I can, but I forget all the time.
from pycodestyle.
And still PEP8 doesn't require that files should not end with blank lines.
from pycodestyle.
I understand each developer has its habits.
I use Vim, and I regularly check my code with pep8.py. I don't see a problem with the default settings.
If you like, you can pass --ignore W29
argument to disable the three warnings which are not strictly PEP8: trailing spaces and new lines at end of file.
from pycodestyle.
Of course developers have habits. Why make it more harder for other people if doesn't make any difference for yourself? Will the presence of \n\n endspace instead of \n bug you more than absence of \n\n bugs me, DXist and other people? You still can apply your rule to count('\n') > 2
from pycodestyle.
W391 is annoying.
from pycodestyle.
@jorgesumle So turn it off? I find it useful.
from pycodestyle.
I remember there was some unix story about those linefeeds at the end of file, so this must be some unix kludge from the past and now is a cargo ritual. =)
from pycodestyle.
Nice point from http://stackoverflow.com/questions/5813311/no-newline-at-end-of-file
The message is displayed because otherwise there is no way to tell the difference between a file where there is a newline at the end and one where is not. Diff has to output a newline anyway, or the result would be harder to read or process automatically.
Note that it is a good style to always put the newline as a last character if it is allowed by the file format. Furthermore, for example, for C and C++ header files it is required by the language standard.
So the last new line is important for diff tools (including Github) and must have for C/C++. I guess early C development toolchain incorrectly handled the last line without line terminator symbols.
I think new line at the end of file is a part of best practices and I dislike editors/IDEs that don't put last new line by default. Rituals support common and clear coding style.
from pycodestyle.
Related Issues (20)
- Fails to detect `E713 test for membership should be 'not in'` when left side more complex than simple variable HOT 1
- Gitdev
- missing description of public interface in documentation HOT 9
- E306 clarification HOT 1
- `exclude` is applied to `.`
- Inconsistent handling of indented comments (E116) HOT 3
- Use setuptools.build_meta HOT 1
- How to get in touch regarding a security concern HOT 2
- Latest version doesn't seem to handle self-documenting f-string syntax added back in 3.8 HOT 1
- pyproject.toml is not supported HOT 1
- False-positive E704 with single-line stubs (black 2024 style) HOT 1
- reporting incorrect information in format strings HOT 1
- Doc: StyleChecker(quiet) not documented HOT 1
- docs directory not shipped in pypi sdist HOT 1
- suppress <name> may be undefined, or defined from star imports HOT 3
- flake8 E704 Errors Triggered by Inline Ellipsis Formatting in Newer black Versions #1926 HOT 1
- docs: meta.pycqa.org code-of-conduct hyperlinks are not redirecting as expected.
- E251: keyword `=` vs. expressions with spaces HOT 1
- Spurious E231 for nested format substitutions
- E122: No valid indent for long function call nested in f-string? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycodestyle.