W1201 logging-not-lazy


'Specify string format arguments as logging function parameters'


Used when a logging statement has a call form of “logging.<logging method>(format_string % (format_args…))”. Such calls should leave string interpolation to the logging method itself and be written “logging.<logging method>(format_string, format_args…)” so that the program may avoid incurring the cost of the interpolation in those cases in which no message will be logged. For more, see http://www.python.org/dev/peps/pep-0282/.


import logging
a = 1
b = 2
logging.debug("State: %d, %d" % (a, b))
4:0: W1201: Use lazy % formatting in logging functions

Here is how you should use it:

import logging
a = 1
b = 2
logging.debug("State: %d, %d", a, b)
No issues found.

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.