[Python-projects] pylint false positive: Unused argument/variable on "-="
Maarten ter Huurne
maarten at treewalker.org
Thu Mar 26 00:25:06 CET 2009
Hi,
Another false positive. Again, I think it is new, but not 100% sure.
===
def exclude(setA, setB):
setA -= setB
===
W0613: 1:exclude: Unused argument 'setA'
Or a variant with a local variable instead of an argument:
===
def exclude(func, setB):
setA = func()
setA -= setB
===
W0612: 2:exclude: Unused variable 'setA'
It seems that the left side of "-=" is not considered a use of the
argument/variable.
The same message is issued for integers as for sets, but for sets a function
like that can actually be useful while for integers it is not. So one could
argue the message make sense for integers and other immutable types where
the value is replaced rather than modified (such as "+=" for strings).
===
def subtract(numB):
numA = 33
numA -= numB
===
W0612: 2:subtract: Unused variable 'numA'
Bye,
Maarten
More information about the Python-Projects
mailing list