Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get PyDev to show pylint errors in the editor?

I have the latest PyDev (2.8.2) and pylint (1.0.0) installed. I am trying to get pylint errors and warnings to show up in the PyDev editor. It seems to do nothing when I enable it. When I set it to redirect output to the console, it seems to be working correctly (see screenshot).

How can I get it working?

Console output

like image 250
Stewart Avatar asked Sep 27 '13 16:09

Stewart


3 Answers

There are quite a few reasons why pylint won't work in PyDev.

Make sure PyLint is configured

The options can be found at window -> preferences -> pydev -> pylint.

Check use pylint?

For Location of pylint.py (lint.py): click the browse button and select the file. For me on Debian GNU/Linux it's at /usr/share/pyshared/pylint/lint.py. If you're on another distribution your package manage should have a way to show you the files that were installed with the pylint package. Search it via grep for lint.py.

If all of that is good, verify that FATAL, ERRORS, WARNINGS, CONVENTIONS, and REFACTOR severities are not set to ignore.

Click OK.

Give it a minute as PyDev may take a moment to get the pylint stuff figured out. Then purposely introduce a pylint warning. Something like an easy foo.bar() when foo isn't defined should create a error that will show up after saving the file.

Make sure you're source files are on the PYTHONPATH

Under Project -> Properties -> PyDev - PYTHONPATH look at the Source Folders tab, if you don't have anything in the box, that's a problem. Add your source directory to it via the Add Source Folder button. If you're code is in the root of the project, just select the project directory. If it's under another folder, select that.

Note: You only need to select the root of the code, not every folder in the project.

Check your extensions

Make sure the file you're testing against has a .py extension. PyDev will not call pylint for any file that does not have a .py extension. So if you have a calling/setup script that calls into the rest of your application that doesn't have a .py extension, it won't check it.

like image 110
grim Avatar answered Nov 10 '22 21:11

grim


First of all make sure that you have autobuild turned on for pylint to work after changes without additional actions. Then check that you don't have more changes than it's configured in option that specifies the maximum delta to use pylint on. And of course enable pylint in problem filters if you haven't already. Think it must help.

like image 43
sepulchered Avatar answered Nov 10 '22 21:11

sepulchered


Your console output is showing binary characters, it could be a file encoding problem. May be your *.py have DOS line endings, if so convert them (seems your box is a Linux one)

dos2unix <your files>

You could also try on the command line the command in the first line of your console. This is how my console looks like

PyLint: Executing command line: /usr/lib/python2.7/site-packages/pylint-1.0.0-py2.7.egg /pylint/lint.py --rcfile=$HOME/.pylintrc test.py
PyLint: The stdout of the command line is: ************* Module updateProgress
C: 14, 0: Line too long (89/80) (line-too-long)
C: 26, 0: Trailing whitespace (trailing-whitespace)
C: 40, 0: Trailing whitespace (trailing-whitespace)
C: 42, 0: Trailing whitespace (trailing-whitespace)
like image 1
LMC Avatar answered Nov 10 '22 23:11

LMC