Skip to content

Commit

Permalink
Include the sample configuration and the list of codes in the documen…
Browse files Browse the repository at this point in the history
…tation, related to issue #112 and issue #139.
  • Loading branch information
florentx committed Dec 22, 2012
1 parent fa2edaa commit af07228
Showing 1 changed file with 182 additions and 2 deletions.
184 changes: 182 additions & 2 deletions docs/intro.rst
Expand Up @@ -154,11 +154,191 @@ Quick help is available on the command line::
--config=path config file location (default: /home/user/.config/pep8)


Configuration
-------------

The behaviour may be configured at two levels.

The user settings are read from the ``~/.config/pep8`` file.
Example::

[pep8]
ignore = E226,E302,E41
max-line-length = 160

At the project's level, a ``.pep8`` file is read if present.

If the ``ignore`` option is not in the configuration and not in the arguments,
only the error codes ``E226`` and ``E241/E242`` are ignored (see below).


Error codes
-----------

The current `list of error codes
<https://github.com/jcrocholl/pep8/wiki/ErrorCodes>`_ is in the Wiki.
This is the current list of error and warning codes:

+----------+----------------------------------------------------------------------+
| code | sample message |
+==========+======================================================================+
| **E1** | *Indentation* |
+----------+----------------------------------------------------------------------+
| E101 | indentation contains mixed spaces and tabs |
+----------+----------------------------------------------------------------------+
| E111 | indentation is not a multiple of four |
+----------+----------------------------------------------------------------------+
| E112 | expected an indented block |
+----------+----------------------------------------------------------------------+
| E113 | unexpected indentation |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E121 | continuation line indentation is not a multiple of four |
+----------+----------------------------------------------------------------------+
| E122 | continuation line missing indentation or outdented |
+----------+----------------------------------------------------------------------+
| E123 | closing bracket does not match indentation of opening bracket's line |
+----------+----------------------------------------------------------------------+
| E124 | closing bracket does not match visual indentation |
+----------+----------------------------------------------------------------------+
| E125 | continuation line does not distinguish itself from next logical line |
+----------+----------------------------------------------------------------------+
| E126 | continuation line over-indented for hanging indent |
+----------+----------------------------------------------------------------------+
| E127 | continuation line over-indented for visual indent |
+----------+----------------------------------------------------------------------+
| E128 | continuation line under-indented for visual indent |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E2** | *Whitespace* |
+----------+----------------------------------------------------------------------+
| E201 | whitespace after '(' |
+----------+----------------------------------------------------------------------+
| E202 | whitespace before ')' |
+----------+----------------------------------------------------------------------+
| E203 | whitespace before ':' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E211 | whitespace before '(' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E221 | multiple spaces before operator |
+----------+----------------------------------------------------------------------+
| E222 | multiple spaces after operator |
+----------+----------------------------------------------------------------------+
| E223 | tab before operator |
+----------+----------------------------------------------------------------------+
| E224 | tab after operator |
+----------+----------------------------------------------------------------------+
| E225 | missing whitespace around operator |
+----------+----------------------------------------------------------------------+
| E226 (*) | missing optional whitespace around operator |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E231 | missing whitespace after ',' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E241 (*) | multiple spaces after ',' |
+----------+----------------------------------------------------------------------+
| E242 (*) | tab after ',' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E251 | no spaces around keyword / parameter equals |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E261 | at least two spaces before inline comment |
+----------+----------------------------------------------------------------------+
| E262 | inline comment should start with '# ' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| E271 | multiple spaces after keyword |
+----------+----------------------------------------------------------------------+
| E272 | multiple spaces before keyword |
+----------+----------------------------------------------------------------------+
| E273 | tab after keyword |
+----------+----------------------------------------------------------------------+
| E274 | tab before keyword |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E3** | *Blank line* |
+----------+----------------------------------------------------------------------+
| E301 | expected 1 blank line, found 0 |
+----------+----------------------------------------------------------------------+
| E302 | expected 2 blank lines, found 0 |
+----------+----------------------------------------------------------------------+
| E303 | too many blank lines (3) |
+----------+----------------------------------------------------------------------+
| E304 | blank lines found after function decorator |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E4** | *Import* |
+----------+----------------------------------------------------------------------+
| E401 | multiple imports on one line |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E5** | *Line length* |
+----------+----------------------------------------------------------------------+
| E501 | line too long (82 > 79 characters) |
+----------+----------------------------------------------------------------------+
| E502 | the backslash is redundant between brackets |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E7** | *Statement* |
+----------+----------------------------------------------------------------------+
| E701 | multiple statements on one line (colon) |
+----------+----------------------------------------------------------------------+
| E702 | multiple statements on one line (semicolon) |
+----------+----------------------------------------------------------------------+
| E711 | comparison to None should be 'if cond is None:' |
+----------+----------------------------------------------------------------------+
| E712 | comparison to True should be 'if cond is True:' or 'if cond:' |
+----------+----------------------------------------------------------------------+
| E721 | do not compare types, use 'isinstance()' |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **E9** | *Runtime* |
+----------+----------------------------------------------------------------------+
| E901 | SyntaxError or IndentationError |
+----------+----------------------------------------------------------------------+
| E902 | IOError |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **W1** | *Indentation warning* |
+----------+----------------------------------------------------------------------+
| W191 | indentation contains tabs |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **W2** | *Whitespace warning* |
+----------+----------------------------------------------------------------------+
| W291 | trailing whitespace |
+----------+----------------------------------------------------------------------+
| W292 | no newline at end of file |
+----------+----------------------------------------------------------------------+
| W293 | blank line contains whitespace |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **W3** | *Blank line warning* |
+----------+----------------------------------------------------------------------+
| W391 | blank line at end of file |
+----------+----------------------------------------------------------------------+
+----------+----------------------------------------------------------------------+
| **W6** | *Deprecation warning* |
+----------+----------------------------------------------------------------------+
| W601 | .has_key() is deprecated, use 'in' |
+----------+----------------------------------------------------------------------+
| W602 | deprecated form of raising exception |
+----------+----------------------------------------------------------------------+
| W603 | '<>' is deprecated, use '!=' |
+----------+----------------------------------------------------------------------+
| W604 | backticks are deprecated, use 'repr()' |
+----------+----------------------------------------------------------------------+

**(*)** In the default configuration, the checks **E226**, **E241**
and **E242** are ignored because they are not rules unanimously accepted,
and `PEP 8`_ does not enforce them.


Note: most errors can be listed with such one-liner::

$ python pep8.py --first --select E,W testsuite/ --format '%(code)s: %(text)s'


.. _related-tools:
Expand Down

0 comments on commit af07228

Please sign in to comment.