You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported by: Ryan Ollos (BitBucket: rjollos, GitHub: @rjollos?)
I've been trying to configure PyLint to check for logging-not-lazy using PyLint 1.3.1. In the Trac project we have cases in which the logger is an attribute of an object.
For example, an Environment object is passed to the initializer and later the logger is utilized through a call self.env.log(...). I haven't had any success getting PyLint to detect the instances of string interpolation when running pylint --disable=all --enable=logging --logging-modules=self.env.log trac/wiki/model.py.
PyLint has no problem detecting the following case:
from trac.log import logger_factory
log = logger_factory()
log.info('Deleted version %d of page %s'
% (version, self.name))
Hm, using logging-modules won't work with anything other than modules. But there's definitely some sort of bug here: https://bitbucket.org/logilab/pylint/src/725447533cbfd90e5bc573eb6debf9bf94dcc799/checkers/logging.py?at=default#cl-140. The Getattr node needs to be inferred, resulting the .info function from the logging module. Checking that the name is something that logs is definitely an improvement from the current situation. If you would like to work on a pull request, I'll be happy to review it, otherwise it will take me some time before having time for a fix.
Closing this as an instance of pylint-dev/astroid#142. Unfortunately there's no way currently for pylint to know that the said object is a logger since it relies on inference to actually detect that. Until we have either type annotation support or until we fix the aforementioned issue, there's not much we can do here.
Originally reported by: Ryan Ollos (BitBucket: rjollos, GitHub: @rjollos?)
I've been trying to configure PyLint to check for logging-not-lazy using PyLint 1.3.1. In the Trac project we have cases in which the logger is an attribute of an object.
For example, an
Environment
object is passed to the initializer and later the logger is utilized through a call self.env.log(...). I haven't had any success getting PyLint to detect the instances of string interpolation when runningpylint --disable=all --enable=logging --logging-modules=self.env.log trac/wiki/model.py
.PyLint has no problem detecting the following case:
I originally posted this on StackOverflow.
The text was updated successfully, but these errors were encountered: