Python

Python

Made by DeepSource

Lazy formatting of message string passed to logging module PYL-W1202

Performance
Minor

Formatting the message manually before passing it to a logging call does unnecessary work if logging in disabled. Consider using the logging module's built-in formatting features to avoid that.

Bad practice

import logging, inspect

logging.basicConfig(level=logging.INFO)
logging.debug("Entered function {}".format(inspect.stack[0][3]))

Recommended

import logging, inspect

logging.basicConfig(level=logging.INFO)
logging.debug("Entered function %s", inspect.stack[0][3])