From ab3c63be3d659c8f5c7654dbdfd88dd6718af47f Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Sat, 15 Nov 2014 18:31:38 +0200 Subject: Move backtick warning in python3 porting checker. --- checkers/format.py | 9 --------- checkers/python3.py | 12 ++++++++++++ test/messages/func_backtick_deprecated_py_30.txt | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/checkers/format.py b/checkers/format.py index 813130b..fe220b1 100644 --- a/checkers/format.py +++ b/checkers/format.py @@ -116,11 +116,6 @@ MSGS = { 'should use a upper case "L" since the letter "l" looks too much ' 'like the digit "1"', {'maxversion': (3, 0)}), - 'W0333': ('Use of the `` operator', - 'backtick', - 'Used when the deprecated "``" (backtick) operator is used ' - 'instead of the str() function.', - {'scope': WarningScope.NODE, 'maxversion': (3, 0)}), 'C0327': ('Mixed line endings LF and CRLF', 'mixed-line-endings', 'Used when there are mixed (LF and CRLF) newline signs in a file.'), @@ -919,10 +914,6 @@ class FormatChecker(BaseTokenChecker): self.add_message('multiple-statements', node=node) self._visited_lines[line] = 2 - @check_messages('backtick') - def visit_backquote(self, node): - self.add_message('backtick', node=node) - def check_lines(self, lines, i): """check lines have less than a maximum number of characters """ diff --git a/checkers/python3.py b/checkers/python3.py index e8609a0..d83709f 100644 --- a/checkers/python3.py +++ b/checkers/python3.py @@ -18,6 +18,7 @@ import tokenize import astroid from pylint import checkers, interfaces +from pylint.utils import WarningScope from pylint.checkers import utils def _check_dict_node(node): @@ -67,6 +68,13 @@ class Python3Checker(checkers.BaseChecker): "instead of 'raise foo(bar)'.", {'maxversion': (3, 0), 'old_names': [('W0121', 'old-raise-syntax')]}), + 'E1606': ('Use of the `` operator', + 'backtick', + 'Used when the deprecated "``" (backtick) operator is used ' + 'instead of the str() function.', + {'scope': WarningScope.NODE, + 'maxversion': (3, 0), + 'old_names': [('W0333', 'backtick')]}), 'W1601': ('apply built-in referenced', 'apply-builtin', 'Used when the apply built-in function is referenced ' @@ -316,6 +324,10 @@ class Python3Checker(checkers.BaseChecker): if isinstance(node.name, (astroid.Tuple, astroid.List)): self.add_message('unpacking-in-except', node=node) + @utils.check_messages('backtick') + def visit_backquote(self, node): + self.add_message('backtick', node=node) + @utils.check_messages('raising-string', 'old-raise-syntax') def visit_raise(self, node): """Visit a raise statement and check for raising diff --git a/test/messages/func_backtick_deprecated_py_30.txt b/test/messages/func_backtick_deprecated_py_30.txt index c78baa1..a4156f7 100644 --- a/test/messages/func_backtick_deprecated_py_30.txt +++ b/test/messages/func_backtick_deprecated_py_30.txt @@ -1,2 +1,2 @@ -W: 4: Use of the `` operator +E: 4: Use of the `` operator -- cgit v1.2.1