[Python-projects] PyLint, jargon, unhelpful error message

Pascal Meunier pmeunier at cerias.net
Fri Jul 24 17:58:59 CEST 2009


Hello PyLint Developers!

I have a suggestion for something that could be done better.  It may be 
the way Python works and PyLint can't do anything about it, in which 
case this is just a rant from a frustrated developer (sorry).  This 
import error message from PyLint (I now realize Python produces a 
similar one) caused me to waste a lot of time:

No name 'a' in module 'module_a'

Setup:
-module_a
	-a.py
	-b.py
	-__init__.py

b.py:
from module_a.a import my_class

a.py contains a syntax error.

$ pylint module_a/b.py
No config file found, using default configuration
************* Module module_a.b
C:  1: Missing docstring
E:  1: No name 'a' in module 'module_a'
W:  1: Unused import my_class

Which I took to mean that there was no file a.py inside the directory 
"module_a" or some problem with the filesystem or the names...  The 
problem was quite different (a syntax error in a.py).  The Python error 
message is just as misleading.  I was scrambling for quite a while 
trying to find out what was wrong in the filesystem or the names I had 
given to the files.

I think that a Python syntax error inside a file should generate 
something more appropriate and helpful than something that sounds like 
the claim that there is no such file!  I understand now that the syntax 
error prevented the name from appearing in the namespace, so from that 
oblique point of view the error message is correct.  However, why on 
earth not report syntax errors as such?  I found no option to increase 
the verbosity of PyLint.

Thanks for maintaining PyLint.

Regards,
Pascal Meunier


More information about the Python-Projects mailing list