Recommended flake8 to check coding style.

This commit is contained in:
Tim Graham 2013-11-07 20:11:37 -05:00
parent e6dd70b4db
commit 14c1872d29
1 changed files with 11 additions and 11 deletions

View File

@ -9,9 +9,12 @@ Python style
* Unless otherwise specified, follow :pep:`8`. * Unless otherwise specified, follow :pep:`8`.
You could use a tool like `pep8`_ to check for some problems in this Use `flake8`_ to check for problems in this area. Note that our ``setup.cfg``
area, but remember that :pep:`8` is only a guide, so respect the style of file contains some excluded files (deprecated modules we don't care about
the surrounding code as a primary goal. cleaning up and some third-party code that Django vendors) as well as some
excluded errors that we don't consider as gross violations. Remember that
:pep:`8` is only a guide, so respect the style of the surrounding code as a
primary goal.
One big exception to :pep:`8` is our preference of longer line lengths. One big exception to :pep:`8` is our preference of longer line lengths.
We're well into the 21st Century, and we have high-resolution computer We're well into the 21st Century, and we have high-resolution computer
@ -194,16 +197,15 @@ Miscellaneous
documentation </topics/i18n/index>` for details. documentation </topics/i18n/index>` for details.
* Remove ``import`` statements that are no longer used when you change code. * Remove ``import`` statements that are no longer used when you change code.
The most common tools for this task are `pyflakes`_ and `pylint`_. `flake8`_ will identify these imports for you. If an unused import needs to
remain for backwards-compatability, mark the end of of with ``# NOQA`` to
silence the flake8 warning.
* Systematically remove all trailing whitespaces from your code as those * Systematically remove all trailing whitespaces from your code as those
add unnecessary bytes, add visual clutter to the patches and can also add unnecessary bytes, add visual clutter to the patches and can also
occasionally cause unnecessary merge conflicts. Some IDE's can be occasionally cause unnecessary merge conflicts. Some IDE's can be
configured to automatically remove them and most VCS tools can be set to configured to automatically remove them and most VCS tools can be set to
highlight them in diff outputs. Note, however, that patches which only highlight them in diff outputs.
remove whitespace (or only make changes for nominal :pep:`8` conformance)
are likely to be rejected, since they only introduce noise rather than
code improvement. Tidy up when you're next changing code in the area.
* Please don't put your name in the code you contribute. Our policy is to * Please don't put your name in the code you contribute. Our policy is to
keep contributors' names in the ``AUTHORS`` file distributed with Django keep contributors' names in the ``AUTHORS`` file distributed with Django
@ -211,6 +213,4 @@ Miscellaneous
change to the ``AUTHORS`` file in your patch if you make more than a change to the ``AUTHORS`` file in your patch if you make more than a
single trivial change. single trivial change.
.. _pep8: http://pypi.python.org/pypi/pep8 .. _flake8: http://pypi.python.org/pypi/flake8
.. _pyflakes: http://pypi.python.org/pypi/pyflakes
.. _pylint: http://pypi.python.org/pypi/pylint