mirror of
https://fuchsia.googlesource.com/third_party/github.com/pylint-dev/pylint
synced 2024-09-22 00:24:37 +00:00
Only emit symbolic warnings from the logging checker.
This commit is contained in:
parent
0370649341
commit
49c88d4b00
|
@ -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):
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user