Skip to content

Commit

Permalink
Recommended flake8 to check coding style.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Nov 9, 2013
1 parent e6dd70b commit 14c1872
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/internals/contributing/writing-code/coding-style.txt
Expand Up @@ -9,9 +9,12 @@ Python style

* Unless otherwise specified, follow :pep:`8`.

You could use a tool like `pep8`_ to check for some problems in this
area, but remember that :pep:`8` is only a guide, so respect the style of
the surrounding code as a primary goal.
Use `flake8`_ to check for problems in this area. Note that our ``setup.cfg``
file contains some excluded files (deprecated modules we don't care about
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.
We're well into the 21st Century, and we have high-resolution computer
Expand Down Expand Up @@ -194,23 +197,20 @@ Miscellaneous
documentation </topics/i18n/index>` for details.

* 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
add unnecessary bytes, add visual clutter to the patches and can also
occasionally cause unnecessary merge conflicts. Some IDE's can be
configured to automatically remove them and most VCS tools can be set to
highlight them in diff outputs. Note, however, that patches which only
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.
highlight them in diff outputs.

* 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
-- not scattered throughout the codebase itself. Feel free to include a
change to the ``AUTHORS`` file in your patch if you make more than a
single trivial change.

.. _pep8: http://pypi.python.org/pypi/pep8
.. _pyflakes: http://pypi.python.org/pypi/pyflakes
.. _pylint: http://pypi.python.org/pypi/pylint
.. _flake8: http://pypi.python.org/pypi/flake8

0 comments on commit 14c1872

Please sign in to comment.