Only emit symbolic warnings from the logging checker.

This commit is contained in:
Torsten Marek 2014-04-17 11:04:41 +02:00
parent 0370649341
commit 49c88d4b00
2 changed files with 8 additions and 8 deletions

View File

@ -149,7 +149,7 @@ class LoggingChecker(checkers.BaseChecker):
return
if isinstance(node.args[format_pos], astroid.BinOp) and node.args[format_pos].op == '%':
self.add_message('W1201', node=node)
self.add_message('logging-not-lazy', node=node)
elif isinstance(node.args[format_pos], astroid.Const):
self._check_format_string(node, format_pos)
@ -180,16 +180,16 @@ class LoggingChecker(checkers.BaseChecker):
return
except utils.UnsupportedFormatCharacter, ex:
char = format_string[ex.index]
self.add_message('E1200', node=node,
self.add_message('logging-unsupported-format', node=node,
args=(char, ord(char), ex.index))
return
except utils.IncompleteFormatString:
self.add_message('E1201', node=node)
self.add_message('logging-format-truncated', node=node)
return
if num_args > required_num_args:
self.add_message('E1205', node=node)
self.add_message('logging-too-many-args', node=node)
elif num_args < required_num_args:
self.add_message('E1206', node=node)
self.add_message('logging-too-few-args', node=node)
def _count_supplied_tokens(args):

View File

@ -20,7 +20,7 @@ class LoggingModuleDetectionTest(CheckerTestCase):
""")
self.checker.visit_module(None)
self.checker.visit_import(stmts[0])
with self.assertAddsMessages(Message('W1201', node=stmts[1])):
with self.assertAddsMessages(Message('logging-not-lazy', node=stmts[1])):
self.checker.visit_callfunc(stmts[1])
def test_detects_renamed_standard_logging_module(self):
@ -30,7 +30,7 @@ class LoggingModuleDetectionTest(CheckerTestCase):
""")
self.checker.visit_module(None)
self.checker.visit_import(stmts[0])
with self.assertAddsMessages(Message('W1201', node=stmts[1])):
with self.assertAddsMessages(Message('logging-not-lazy', node=stmts[1])):
self.checker.visit_callfunc(stmts[1])
@set_config(logging_modules=['logging', 'my.logging'])
@ -41,7 +41,7 @@ class LoggingModuleDetectionTest(CheckerTestCase):
""")
self.checker.visit_module(None)
self.checker.visit_import(stmts[0])
with self.assertAddsMessages(Message('W1201', node=stmts[1])):
with self.assertAddsMessages(Message('logging-not-lazy', node=stmts[1])):
self.checker.visit_callfunc(stmts[1])