How to write a pep8 configuration (pep8.rc) file?

Aditya Srivastava picture Aditya Srivastava · May 18, 2015 · Viewed 10.9k times · Source

I found the documentation for pep8 but wasn't able to understand how to write these. I couldn't even find any examples with options other than setting max-line-length and ignore.

I am trying to write a .pep8.rc file in which, among other things, I need to do the following:

  • enable show source
  • enable statistics
  • enable count
  • exclude a directory (say, for example ./random)

Can somebody answer with an example or link to one?

Answer

Andy Hayden picture Andy Hayden · Dec 17, 2015

The preferred way is to use a setup.cfg in the top-level of the project (.cfg has the same syntax as a .ini file), which should contain a [pep8] section. For example:

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

Note: the error codes are defined in the pep8 docs.