[Python-projects] pylint false positive: Unused argument/variable on "-="
skip at pobox.com
skip at pobox.com
Thu Mar 26 01:44:17 CET 2009
Maarten> The "setA" variable itself is indeed unused. But the value of
Maarten> the object that "setA" refers to is most likely used somewhere
Maarten> outside this function. For example:
I'd still argue that the warning will catch errors and is still useful.
pylint can't tell whether setA is immutable or not, so it can't tell if the
-= operator has side effects.
Maarten> a = set(range(10))
Maarten> exclude(a, set(range(5, 15)))
Maarten> print a
What if I called it like this?
exclude(4, 1)
? That's a perfectly legal, though somewhat silly, way to call exclude().
In fact, when you originally presented just the exclude function without an
example, I saw the -= operator and immediately thought "ah, numbers".
Skip
More information about the Python-Projects
mailing list