views:

1043

answers:

2

A little background:

  • PEP 8 is the Style Guide for Python Code. It contains the conventions all python programmers should follow.
  • pep8.py is a (very useful) script that checks the code formating of a given python script, according to PEP 8.
  • Eclipse is a great IDE. With the Pydev extension, it that can be used to develop Python

I run pep8.py manually when I'm scripting, but with bigger projects I prefer to use Eclipse. It would be really useful to integrate pep8.py in Eclipse/Pydev, so it can be run automatically in all the files in the project, and point to the lines containing the warnings. Maybe there is an obvious way to do it, but I haven't found it yet.

Question is: How to integrate pep8.py in Eclipse?

+5  A: 

That does not yet appear to be fully integrated into Pydev.

As suggested in this post,

[it] would require changing the code within pydev -- a flexible option would be adding preferences to let the user choose to which patterns he wants to match for creating hyperlinks (and saying which group in the match is the line and which one is the file)...

Or, you can try it hard-coded playing with: org.python.pydev.debug.ui.PythonConsoleLineTracker (should be pretty easy to grasp).

A request does exist for just that, but it seems to be still open 1 year after its creation...

VonC
+8  A: 

I don't know how to integrate it for whole project, but I've done a bit more convenient way to use it -- as an external tool. You should do following:

  1. Select Run-External Tools-External Tools Configurations...
  2. Select Program root node.
  3. Press New launch configuration button.
  4. Enter Name for your launch configuration. I use 'pep8'.
  5. Fill following fields:

    Location -- C:\Python26\Scripts\pep8.exe (yours can be differ, surely).

    Working directory -- ${container_loc}

    Arguments -- ${resource_name} (I don't know Eclipse too well, it works for me and it takes currently opened file in editor).

Go to Common tab and make sure that Allocate Console checkbox is checked. That's it.

Dmitry Kochkin
I found correct way of setting working directory and edit my answer!
Dmitry Kochkin