Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

linty freshness

Sean Myers edited this page Sep 26, 2013 · 11 revisions

flake8

There are many handy tools that can be used to check your code against established python style. A tool called flake8 exists to combine these tools into one easy-to-use package. flake8 is used by reviewers on pull requests for style compliance, so it's a good idea to run flake8 before submitting code for review.

Manual Invocation

To use flake8 in our project, first install it:

  • pip install flake8 or
  • easy_install flake8

Some flags are required to deal with our specific alterations to python style:

  • We allow lines up to 100 characters in length; add --max-line-length=100
  • We indent block statement line continuations twice, even in function defs; add --ignore=E128

Then, aim it at the python file (or files) being edited: flake8 --max-line-length=100 --ignore=E128 path/to/python_module.py flake8 --max-line-length=100 --ignore=E128 path/to/python/package/

These settings can be stored as defaults in a config file. By default, flake8 looks in ~/.config/flake8. Here is an example file that adheres to our style guidelines:

[flake8]
ignore = E128
max-line-length = 100

IDE Integration

Sublime Text 2 & 3

The excellent Flake8Lint package for the sublime text editor will do automatic linting using the flake8 tool. To configure it to follow our guidelines, Add the following options to your Flake8Lint.sublime-settings file:

"pep8_max_line_length": 100
"ignore": ["E128"]

Others

If your IDE isn't listed here, feel free to add instructions above!

Clone this wiki locally