I want to be PEP8 compliant when coding Python in Eclipse (with as little effort as possible). Shows how to enable automatic checking of PEP8 and automatic conversion to PEP8 in Eclipse + PyDev.
Eclipse plugin for Python.
http://www.pydev.org/index.html
PyDev is a Python IDE for Eclipse, which may be used in Python, Jython and IronPython development.
It comes with many goodies such as:
http://www.pydev.org/manual_101_install.html It is organized in an easy-to-understand manner with screenshots.
Python coding conventions. See below for details.
PyDev comes standard with pep8 and autopep8. With these two, PEP8 compliance check and automatic conversion to PEP8 can be performed.
pep8 A tool that checks for PEP8 compliance and outputs the violations. It can be used alone as a command line tool.
https://pypi.python.org/pypi/pep8
pep8 - Python style guide checker
pep8 is a tool to check your Python code against some of the style conventions in PEP 8.
autopep8 A tool that converts source code into a PEP8 compliant format. Easy to comply with PEP8. It can be used alone as a command line tool.
https://pypi.python.org/pypi/autopep8Use
A tool that automatically formats Python code to conform to the PEP 8 style guide
Window
-> Preferences
-> PyDev
-> Editor
-> Code Analysis
so
Check Do code analysis?
On the ʻOptions` tab.
Check other than Don't run
on the pep8.py
tab.
Window
-> Preferences
-> PyDev
-> Editor
-> Code Style
-> Code Formatter
so
ʻCheck Use autopep8.py for code formatting?`.
Window
-> Preferences
-> PyDev
-> Editor
-> Save Actions
so
ʻCheck Auto-format editor contents before saving?`.
With this setting, even if you are not coding with PEP8 in mind When saving, autopep8 works and makes the code PEP8 compliant.
Just running autopep8 does not make the code fully PEP8 compliant. However, it's mostly compliant, so it's easier than fixing everything manually. After running autopep8, a warning will be issued with pep8, so fix it manually.
Window
-> Preferences
-> PyDev
-> Editor
-> Save Actions
of
Sort imports on save?
If you check the box, the import modules will be sorted in alphabetical order when saving.
This is also set because it is troublesome to do it manually.