diff options
-rw-r--r-- | pylint/checkers/format.py | 11 | ||||
-rw-r--r-- | tests/checkers/unittest_format.py | 4 |
2 files changed, 5 insertions, 10 deletions
diff --git a/pylint/checkers/format.py b/pylint/checkers/format.py index 24618923c..130ddd0c5 100644 --- a/pylint/checkers/format.py +++ b/pylint/checkers/format.py @@ -352,7 +352,7 @@ class FormatChecker(BaseTokenChecker): self.check_lines(line, line_num) def process_module(self, _module): - self._keywords_with_parens = set() + pass def _check_keyword_parentheses(self, tokens: List[TokenInfo], start: int) -> None: """Check that there are not unnecessary parens after a keyword. @@ -401,11 +401,10 @@ class FormatChecker(BaseTokenChecker): self.add_message( "superfluous-parens", line=line_num, args=keyword_token ) - elif keyword_token not in self._keywords_with_parens: - if not found_and_or: - self.add_message( - "superfluous-parens", line=line_num, args=keyword_token - ) + elif not found_and_or: + self.add_message( + "superfluous-parens", line=line_num, args=keyword_token + ) return elif depth == 1: # This is a tuple, which is always acceptable. diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py index 75b0c7967..7c07ac9ed 100644 --- a/tests/checkers/unittest_format.py +++ b/tests/checkers/unittest_format.py @@ -137,7 +137,6 @@ class TestSuperfluousParentheses(CheckerTestCase): CHECKER_CLASS = FormatChecker def testCheckKeywordParensHandlesValidCases(self): - self.checker._keywords_with_parens = set() cases = [ "if foo:", "if foo():", @@ -157,7 +156,6 @@ class TestSuperfluousParentheses(CheckerTestCase): self.checker._check_keyword_parentheses(_tokenize_str(code), 0) def testCheckKeywordParensHandlesUnnecessaryParens(self): - self.checker._keywords_with_parens = set() cases = [ (Message("superfluous-parens", line=1, args="if"), "if (foo):", 0), (Message("superfluous-parens", line=1, args="if"), "if ((foo, bar)):", 0), @@ -187,7 +185,6 @@ class TestSuperfluousParentheses(CheckerTestCase): self.checker._check_keyword_parentheses(_tokenize_str(code), offset) def testCheckIfArgsAreNotUnicode(self): - self.checker._keywords_with_parens = set() cases = [("if (foo):", 0), ("assert (1 == 1)", 0)] for code, offset in cases: @@ -205,7 +202,6 @@ print('Hello world!') self.checker.process_tokens(_tokenize_str(code)) def testKeywordParensFalsePositive(self): - self.checker._keywords_with_parens = set() code = "if 'bar' in (DICT or {}):" with self.assertNoMessages(): self.checker._check_keyword_parentheses(_tokenize_str(code), start=2) |