Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 423
Aditya Srivastava Avatar asked May 18 '15 13:05

Aditya Srivastava


People also ask

What is a pep in Python?

PEP stands for Python Enhancement Proposal. A PEP is a technical design doc for the Python community which describes a new feature for the language itself, its processes, or its environment.

Does Flake8 follow PEP8?

Flake8 plugins are easier to write relative to PyLint plugins, in terms of, lines of code. It enforces PEP8 which is, in fact, the whole point!

Which of the following modules warn about pp8 inconsistencies present in Python script?

pep8 warn about 8-space indent.


1 Answers

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.


  • autopep8 find this same [pep8] section as pep8.
  • flake8 needs a [flake8] section in setup.cfg.
  • yapf looks for a [yapf] section in setup.cfg.
like image 62
Andy Hayden Avatar answered Oct 13 '22 18:10

Andy Hayden