Skip to content

Commit 182cc53

Browse files
authored
Use value directly instead of index in enumerate contexts (#5856)
Refactoring to prevent warnings being issued on these lines from a new proposed checker.
1 parent 843a8ff commit 182cc53

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pylint/checkers/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def table_lines_from_stats(
124124
("error", "NC"),
125125
]
126126

127-
for index, _ in enumerate(new):
128-
new_value = new[index][1]
127+
for index, value in enumerate(new):
128+
new_value = value[1]
129129
old_value = old[index][1]
130130
diff_str = (
131131
diff_string(old_value, new_value)
@@ -134,7 +134,7 @@ def table_lines_from_stats(
134134
)
135135
new_str = f"{new_value:.3f}" if isinstance(new_value, float) else str(new_value)
136136
old_str = f"{old_value:.3f}" if isinstance(old_value, float) else str(old_value)
137-
lines.extend((new[index][0].replace("_", " "), new_str, old_str, diff_str))
137+
lines.extend((value[0].replace("_", " "), new_str, old_str, diff_str))
138138
return lines
139139

140140

pylint/checkers/refactoring/refactoring_checker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,12 @@ def process_tokens(self, tokens):
578578
token_string = token[1]
579579
if token_string == "elif":
580580
# AST exists by the time process_tokens is called, so
581-
# it's safe to assume tokens[index+1]
582-
# exists. tokens[index+1][2] is the elif's position as
581+
# it's safe to assume tokens[index+1] exists.
582+
# tokens[index+1][2] is the elif's position as
583583
# reported by CPython and PyPy,
584-
# tokens[index][2] is the actual position and also is
584+
# token[2] is the actual position and also is
585585
# reported by IronPython.
586-
self._elifs.extend([tokens[index][2], tokens[index + 1][2]])
586+
self._elifs.extend([token[2], tokens[index + 1][2]])
587587
elif _is_trailing_comma(tokens, index):
588588
if self.linter.is_message_enabled("trailing-comma-tuple"):
589589
self.add_message("trailing-comma-tuple", line=token.start[0])

0 commit comments

Comments
 (0)