Pylint logging checker doesn't recognize logging module-Level functions

Viewed 94

Can someone help on how to make pylint recognize logger subclass

Eg., logging.error("{}".format(APPLE)) works fine when the

logging-format-style=new
logging-modules=format

are set in pylintrc. But, for the same config,

logger = logging.getLogger()
logger.error("{}".format(APPLE)) 

pylint throws error :

Use lazy % formatting in logging functions (logging-format-interpolation)
1 Answers

A linter is there to tell you when you aren't doing things quite right. That's why it's flagging up that call - you're not using best practice, which is lazy evaluation of the message using % formatting. Using logger.error("%s", APPLE) would avoid that linter complaint.

Related