[Python-projects] Accepting variable refs in str % locals()

skip at pobox.com skip at pobox.com
Wed Mar 26 00:37:38 CET 2008


Pylint complaints about unused variables when you have code like this:

    def f(a, c=None):
        b = 47
        return "a=%(a)s b=%(b)s" % locals()

though of course a and b are actually used.  I think the attached patch to
checkers/variables.py should improve the situation.  This is my first
attempt to extend pylint, so there are no doubt some questionable
constructs.

With the patch applied pylint only reports c as unused in the above
function.  I don't have a current checkout of pylint.  The patch is against
a snapshot from last October.  The __pkginfo__.py file reports the version
as (0, 13, 2).

-- 
Skip Montanaro - skip at pobox.com - http://www.webfast.com/~skip/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pylint.diff
Type: application/octet-stream
Size: 1927 bytes
Desc: not available
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20080325/f8af2f4f/attachment.obj 


More information about the Python-Projects mailing list