Skip to content

Commit 95f3fc3

Browse files
brycepgPCManticore
authored andcommitted
Remove unused member variable of FormatChecker
1 parent 83a1f49 commit 95f3fc3

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

pylint/checkers/format.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def new_line(self, tokens, line_end, line_start):
352352
self.check_lines(line, line_num)
353353

354354
def process_module(self, _module):
355-
self._keywords_with_parens = set()
355+
pass
356356

357357
def _check_keyword_parentheses(self, tokens: List[TokenInfo], start: int) -> None:
358358
"""Check that there are not unnecessary parens after a keyword.
@@ -401,11 +401,10 @@ def _check_keyword_parentheses(self, tokens: List[TokenInfo], start: int) -> Non
401401
self.add_message(
402402
"superfluous-parens", line=line_num, args=keyword_token
403403
)
404-
elif keyword_token not in self._keywords_with_parens:
405-
if not found_and_or:
406-
self.add_message(
407-
"superfluous-parens", line=line_num, args=keyword_token
408-
)
404+
elif not found_and_or:
405+
self.add_message(
406+
"superfluous-parens", line=line_num, args=keyword_token
407+
)
409408
return
410409
elif depth == 1:
411410
# This is a tuple, which is always acceptable.

tests/checkers/unittest_format.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class TestSuperfluousParentheses(CheckerTestCase):
137137
CHECKER_CLASS = FormatChecker
138138

139139
def testCheckKeywordParensHandlesValidCases(self):
140-
self.checker._keywords_with_parens = set()
141140
cases = [
142141
"if foo:",
143142
"if foo():",
@@ -157,7 +156,6 @@ def testCheckKeywordParensHandlesValidCases(self):
157156
self.checker._check_keyword_parentheses(_tokenize_str(code), 0)
158157

159158
def testCheckKeywordParensHandlesUnnecessaryParens(self):
160-
self.checker._keywords_with_parens = set()
161159
cases = [
162160
(Message("superfluous-parens", line=1, args="if"), "if (foo):", 0),
163161
(Message("superfluous-parens", line=1, args="if"), "if ((foo, bar)):", 0),
@@ -187,7 +185,6 @@ def testCheckKeywordParensHandlesUnnecessaryParens(self):
187185
self.checker._check_keyword_parentheses(_tokenize_str(code), offset)
188186

189187
def testCheckIfArgsAreNotUnicode(self):
190-
self.checker._keywords_with_parens = set()
191188
cases = [("if (foo):", 0), ("assert (1 == 1)", 0)]
192189

193190
for code, offset in cases:
@@ -205,7 +202,6 @@ def testFuturePrintStatementWithoutParensWarning(self):
205202
self.checker.process_tokens(_tokenize_str(code))
206203

207204
def testKeywordParensFalsePositive(self):
208-
self.checker._keywords_with_parens = set()
209205
code = "if 'bar' in (DICT or {}):"
210206
with self.assertNoMessages():
211207
self.checker._check_keyword_parentheses(_tokenize_str(code), start=2)

0 commit comments

Comments
 (0)