User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

In every software development project adhering to coding standards is a must (even if the code will be read and used by a single author). Python is not the exception, there are coding guidelines that cover all the relevant pieces, and those are all included in the Python Enhancement Proposal 8

Sometimes is hard to keep track of all those guidelines, and to help with this, a Python tool called Pylint has been developed.

This article will guide you step-by-step on how to configure Pylint in the Eclipse IDE in order to do auto-formatting and inspect your code for continuous improvement.

  1.  Install PyLint:

    py -3 -m pip install pylint

  2. Launch Eclipse
  3. Go to Window->Preferences
  4. Go to PyDev->Editor->Code Analysis->PyLint
  5. Check "Use PyLint"
  6. Check "Redirect PyLint output to console?"
  7. Select "Specify Location"
  8. Browse to your Python/Script folder, and select pylint[.exe]
  9. Set the following configuration:

    FATAL: Error
    ERRORS: Error
    WARNINGS: Warning
    CONVENTIONS: Ignore
    REFACTOR: Ignore

  10. In the argument text area, enter:

    --max-line-length=120

  11. If required, configure any of your project folder as a source folder.
  12. Go to Project->Properties
  13. Select PyDev - PYTHONPATH
  14. Click on "Add Source Folder"
  15. Select the project.
  16. Click "OK"
  17. Click on "Add Source Folder"
  18. Select the folder.
  19. Click "OK"
  20. Click "Apply and Close"

 

Now, every time you save the file you're editing, Eclipse will execute pylint to inspect the code. You should expect to see:

  • Code format automatically updated.
  • Indicators about the error tolerance of your code in the 'Console' view.

 

This will give you enough to play and improve your coding skills.