Skip to content

Commit

Permalink
Remove unused member variable of FormatChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
brycepg committed Jun 16, 2020
1 parent 50f7b16 commit ba0c794
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 5 additions & 6 deletions pylint/checkers/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def new_line(self, tokens, line_end, line_start):
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.
Expand Down Expand Up @@ -401,11 +401,10 @@ def _check_keyword_parentheses(self, tokens: List[TokenInfo], start: int) -> Non
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.
Expand Down
4 changes: 0 additions & 4 deletions tests/checkers/unittest_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ class TestSuperfluousParentheses(CheckerTestCase):
CHECKER_CLASS = FormatChecker

def testCheckKeywordParensHandlesValidCases(self):
self.checker._keywords_with_parens = set()
cases = [
"if foo:",
"if foo():",
Expand All @@ -157,7 +156,6 @@ def testCheckKeywordParensHandlesValidCases(self):
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),
Expand Down Expand Up @@ -187,7 +185,6 @@ def testCheckKeywordParensHandlesUnnecessaryParens(self):
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:
Expand All @@ -205,7 +202,6 @@ def testFuturePrintStatementWithoutParensWarning(self):
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)
Expand Down

0 comments on commit ba0c794

Please sign in to comment.