attribute: Phillie Casablanca

Eclipse and Pylint on windows

I've been using eclipse and pydev for python development for a little over a year now.

I've read recently about a tool called 'pylint' that can point out possible errors in you code.
And apparently it can be used with pydev, but is turned off by default.

I decided to try it out, but first I when I just went into the preferences with our reading much and flipped the toggle, I got the following error:

Pylint: Executing command line:' C:\Program Files\eclipse --include-ids=y D:\PROGRAMMING\Workspace\SimpleReview\src\sr_interface.py 'Pylint: The stdout of the command line is: Pylint: The stderr of the command line is: c:\python26\python.exe: can't find '__main__.py' in 'C:\\Program Files\\eclipse'

Reading a little deeper I figured out I needed to actually install pylint and set the path to that file in the eclipse pydev preferences.

So I downloaded pylint, unzipped and ran, "python setup.py install".
http://www.logilab.org/project/pylint/


running install
running build
running build_py
package init file '.\test\__init__.py' not found (or not a regular file)
package init file '.\test\__init__.py' not found (or not a regular file)
running build_scripts
error: file 'bin\epylint.bat' does not exist

Ok, so I wasn't sure what was wrong here, but decided to open the readme. It lists the following dependancies, so let's install those and see what happens:

http://www.logilab.org/projects/astng
http://www.logilab.org/projects/common

Alright, these install ok. Then trying install for pylint I got the same error, "bin/epylint.bat doesn't exist". Ok, a google search turned up this sparse post:

http://shurik.posterous.com/pylint-on-windows

Which basically tells you to create the file yourself and put the following text in it:

epylint.bat


python epylint %*

And then run, "python setup.py install" again, and it worked. Strange.

So, now when I edit a python file and save it pylint runs and I get some output. Not too sure what it means yet, but I'll leave it on for awhile and see if it starts to make sense.

Here's a sample run on a bad file that won't run:


C0301: 8: Line too long (135/80)
C0111: 1: Missing docstring
C0103: 3: Invalid name "strComputer" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C0103: 4: Invalid name "objWMIService" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
E0602: 4: Undefined variable 'win32com'
C0103: 5: Invalid name "objSWbemServices" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C0324: 7: Comma not followed by a space
query_str = '''Select * from %s%s''' % (self.win32_perf_base,counter_type)
^^
C0103: 7: Invalid name "query_str" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
E0602: 7: Undefined variable 'self'
E0602: 7: Undefined variable 'counter_type'
C0103: 8: Invalid name "colItems" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)

Report
======
5 statements analysed.

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |5 |55.56 |NC |NC |
+----------+-------+------+---------+-----------+
|docstring |0 |0.00 |NC |NC |
+----------+-------+------+---------+-----------+
|comment |0 |0.00 |NC |NC |
+----------+-------+------+---------+-----------+
|empty |4 |44.44 |NC |NC |
+----------+-------+------+---------+-----------+

Duplication
-----------

+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |0 |NC |NC |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |NC |NC |
+-------------------------+------+---------+-----------+

Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |1 |NC |NC |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |0 |NC |NC |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |0 |NC |NC |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |0 |NC |NC |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+

Messages by category
--------------------

+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |8 |NC |NC |
+-----------+-------+---------+-----------+
|refactor |0 |NC |NC |
+-----------+-------+---------+-----------+
|warning |0 |NC |NC |
+-----------+-------+---------+-----------+
|error |3 |NC |NC |
+-----------+-------+---------+-----------+

Messages
--------

+-----------+-----------+
|message id |occurences |
+===========+===========+
|C0103 |5 |
+-----------+-----------+
|E0602 |3 |
+-----------+-----------+
|C0324 |1 |
+-----------+-----------+
|C0301 |1 |
+-----------+-----------+
|C0111 |1 |
+-----------+-----------+

Global evaluation
-----------------
Your code has been rated at -36.00/10

Pylint: The stderr of the command line is: No config file found, using default configuration

monkut // Dec. 2, 2008 // 12:18 a.m. // 0 Comments