W0612 unused-variable

Message

'Unused variable %r'

Description

Used when a variable is defined but not used.

Examples

def example():
    foo = 1
    return 1
2:4: W0612: Unused variable 'foo'

In the following example, we misspelled a argument name, leaving the real argument unused.

def example():
    foo = 1
    return boo
2:4: W0612: Unused variable 'foo'

Why bother?

Often this kind of issue gives us a hint that we are using the wrong variable in some place.

If that is not the case, it is still worth fixing because the unncesseary variable

  • makes the code harder to undestand

  • and/or leads to wasted CPU cycles.

Running Pylint locally? In your CI?

There is a better way! Run PyCodeQual & get Pylint findings with history, diffs and statistics.

Click here to find out more.