Skip to content

Commit

Permalink
Fix regressions from new unnecessary-list-lookup checker (pylint-dev#…
Browse files Browse the repository at this point in the history
…4525)

Refactoring to prevent warnings being issued on these lines from a new
checker.
  • Loading branch information
timmartin committed Mar 2, 2022
1 parent 843a8ff commit 4968ce9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pylint/checkers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def table_lines_from_stats(
("error", "NC"),
]

for index, _ in enumerate(new):
new_value = new[index][1]
for index, value in enumerate(new):
new_value = value[1]
old_value = old[index][1]
diff_str = (
diff_string(old_value, new_value)
Expand All @@ -134,7 +134,7 @@ def table_lines_from_stats(
)
new_str = f"{new_value:.3f}" if isinstance(new_value, float) else str(new_value)
old_str = f"{old_value:.3f}" if isinstance(old_value, float) else str(old_value)
lines.extend((new[index][0].replace("_", " "), new_str, old_str, diff_str))
lines.extend((value[0].replace("_", " "), new_str, old_str, diff_str))
return lines


Expand Down
8 changes: 4 additions & 4 deletions pylint/checkers/refactoring/refactoring_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,12 @@ def process_tokens(self, tokens):
token_string = token[1]
if token_string == "elif":
# AST exists by the time process_tokens is called, so
# it's safe to assume tokens[index+1]
# exists. tokens[index+1][2] is the elif's position as
# it's safe to assume tokens[index+1] exists.
# tokens[index+1][2] is the elif's position as
# reported by CPython and PyPy,
# tokens[index][2] is the actual position and also is
# token[2] is the actual position and also is
# reported by IronPython.
self._elifs.extend([tokens[index][2], tokens[index + 1][2]])
self._elifs.extend([token[2], tokens[index + 1][2]])
elif _is_trailing_comma(tokens, index):
if self.linter.is_message_enabled("trailing-comma-tuple"):
self.add_message("trailing-comma-tuple", line=token.start[0])
Expand Down

0 comments on commit 4968ce9

Please # to comment.