-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Enhancement β¨Improvement to a componentImprovement to a component
Description
Pylint will warn against using .format and % when logging. As the example below shows, I think it would be prudent to also output warnings when using f-strings.
Steps to reproduce
"""Docstring"""
import logging
def main():
"""Main"""
url = 'http://example.com/%fe'
# This works:
logging.error(
'url is %s | log method: %s', url, 'logging with parameters only')
# This will crash the logger, but pylint will output
# logging-format-interpolation:
logging.error(
'url is {} | log method: %s'.format(url), 'logging with .format')
# This will also crash the logger, but pylint accepts it:
logging.error(f'url is {url} | log method: %s', 'logging with f-string')
main()Current behavior
Pylint does not warn against f-string interpolation in loggers.
Expected behavior
Pylint should warn against f-string interpolation in loggers, just as it warns against .format-interpolation.
pylint --version output
pylint 1.8.1,
astroid 1.6.0
Python 3.6.2 (default, Sep 22 2017, 12:45:49)
[GCC 6.3.0 20170516]
Suor and mgedminsrgraham, kevlarr, pbelskiy, zbarry, beac0n and 16 more
Metadata
Metadata
Assignees
Labels
Enhancement β¨Improvement to a componentImprovement to a component