Use lazy % formatting in logging functions
45 if not version:
46 continue
47 if ret and tag_date + timedelta(days=365) < ret['tag_date']:
48 log.info('The version {} is newer, but is too old!'.format(version))49 break
50 if not ret or ret and version > ret['version']:
51 log.info("Setting version as current selection: {}.".format(version))
Use lazy % formatting in logging functions
48 log.info('The version {} is newer, but is too old!'.format(version))
49 break
50 if not ret or ret and version > ret['version']:
51 log.info("Setting version as current selection: {}.".format(version))52 ret = t
53 ret['tag_name'] = tag
54 ret['tag_date'] = tag_date
Description
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])