[Python-projects] Some false positives from pylint

Marc 'BlackJack' Rintsch marc at rintsch.de
Sat May 20 14:49:30 CEST 2006


Hi *,

The `constant` naming regex flags functions as constants.  While they 
are constants to some degree, I don't think they should be written in 
all caps::

 def make_adder(add_value):
     def adder(num):
         return num + add_value
     return adder

 add5 = make_adder(5)

 def new_name():
     pass

 old_name_or_synonym = new_name

I guess it's not in the scope of pylint to recognize closures but maybe 
there's enough information available to get simple synonyms for 
``def``\ed functions?

I've used this extensivly to define functions that read metadata from 
multimedia files.  There's a default dummy function assigned to the 
function name first and then, depending on the availablity of external 
modules it may be rebound to a function that actually is able to read 
the metadata from a given filetype.

In the same program I get plenty of ``Instance of 'None' has no 'XYZ' 
member`` because I've initialized some variables with `None` 
first.  :-/

Another false alarm::

 item = None
 for item in xrange(5):
     pass
 print item

 item2 = None
 TEST = [item2 for item2 in xrange(5)]
 print item2

There's a ``Using possibly undefined loop variable 'item(2)'`` warning 
for both ``print`` statement lines.

Ciao,
	Marc 'BlackJack' Rintsch
-- 
“A programming language is low level when its
 programs require attention to the irrelevant.”
                              -- Alan J. Perlis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20060520/79531c91/attachment.pgp


More information about the Python-Projects mailing list