Silence PyLint warning about unused variables for string interpolation

Eleno picture Eleno · Feb 17, 2016 · Viewed 36.5k times · Source

The say module brings string interpolation to Python, like this:

import say

def f(a):
    return say.fmt("The value of 'a' is {a}")

However, PyLint complains that the variable 'a' is never used. This is a problem because my code uses say.fmt extensively. How can I silence this warning?

Answer

Robᵩ picture Robᵩ · Feb 17, 2016

Yes, you can silence pylint warnings.

Here is one way:

import say

def f(a):
    #pylint: disable=unused-argument
    return say.fmt("The value of 'a' is {a}")

Alternatively, you can create a config file and add these lines to it:

[MESSAGES CONTROL]
disable=unused-argument

Reference: