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?
This may be done by adding # pylint: disable=some-message,another-one at the desired block level or at the end of the desired line of code.
To suppress the warning, one can simply name the variable with an underscore ('_') alone. Python treats it as an unused variable and ignores it without giving the warning message.
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:
One approach to silencing that message is to name or prefix the argument with dummy
or _
, as in:
import say def f(_a): return say.fmt("The value of 'a' is {_a}")
See here for more info: https://stackoverflow.com/a/10107410/1080804
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With