You are here: Home / Blog / Using pep8 checks in eclipse

Using pep8 checks in eclipse

Tutorial how to integrate pep8 checks into eclipse.

Buildout

I used buildout to generate a pep8 check binary in my ${buildout:directory}/bin directory. I can now use it from command line or run it as an external programm from eclipse.

[buildout]
parts = 
    ...
    pep8
    ...

[pep8]
recipe = zc.recipe.egg
eggs = pep8
entry-points = pep8check=pep8:_main
dirs = ['src/my.product', ]
scripts = pep8check
initialization = sys.argv.extend(${pep8:dirs})

After (re)running buildout you should have an pep8check executable in your bin/ folder.

daniel:~/sandbox/project/ $ ls -l bin/ | grep pep8
-rwxr-xr-x  1 daniel  staff    408 22 Mar 17:29 pep8check

Executing this file runs a pep8 check on each file in your-product.package.

daniel:~/sandbox/project/ $ bin/pep8check
src/my.product/my/product/expiration.py:26:50: E261 at least two spaces before inline comment
src/my.product/my/product/expiration.py:47:5: E303 too many blank lines (2)
src/my.product/my/product/logger.py:18:17: E202 whitespace before '}'
src/my.product/my/product/logger.py:49:1: W291 trailing whitespace

Using direct eclipse integration

  1. Open External Tools Configuration dialog (you'll find it in main menu Run->External Tools->External Tools Configuration).

    External Tools Configuration

  2. You can use several variables to access your executable or working directory. Arguments are not required because they were already added in buildout configuration.

    If you are using the same buildout configuration as i posted above you should use ${project_loc}/bin/pep8check for executable and ${project_loc} for working directory.

    External Tools Configuration

Using Aptana Studio 3.0

Aptana Studio 3.0 is shipped with pydev and many other tools, pep8 is included too. This offers you a much more comfortable way to enable pep8 checks, because you see'll your code analysis result while you're developing code.

  1. Open Settings PyDev -> Editor -> Code Analysis and enable Code Analysis in first tab.

    Enable Code Analysis in Eclipse
  2. Go to last Tab and check pep8 path. The path was correct on my system out of the box, i just added one ignore rule, multiple rules can be splitted by ', '. Read pep8 documentation to get more info about these --ignore options. 

    Aptana Studio 3.0 Configuration
Renier says:
Nov 20, 2013 11:02 AM
I am using aptana studio 3, and I am developing Pyramid application.
I have set up a virtual env and I am Run this from Aptana studio.
Could this stop the pep8 check from working? because its not working...
Add comment

You can add a comment by filling out the form below. Plain text formatting. Web and email addresses are transformed into clickable links.

Question: What is 4 - 1 ?
Your answer: