[Python-projects] pylint: unused local variables and their context]

Duncan Gibson duncan.gibson at xs4all.nl
Thu Nov 30 18:34:17 CET 2006


Must remember to "Reply-All" next time :-)

> pylint is throwing up "unused variable" warnings for code such as:
> 	for x in range(0, MAX):
> 		some_code()

> Another example:
> 	x, y, z = self.getCoords()
> 	self.checkxy(x, y)
>
> (I know that we could simply name those variables in a way that pylint
> ignores them, but I'd much prefer a transparent solution)

I would rename to "unused_x" because I changed my pylintrc to have:
dummy-variables-rgx=(_|dummy|(unused.*))

but you don't want to do that. You could run pylint --disable-msg=W0612
or add the following comment to your file, function, method, line:
#pylint: disable-msg=W0612

I have a related question though:

If I disable a particular message using a comment in the code, can I
re-enable it from the command line at a later date? I want to make sure
that I don't mask any problems that I might introduce after adding the
comment.

Cheers
Duncan





More information about the Python-Projects mailing list