Skip to content

Commit c9b98e4

Browse files
committed
add support for Call node
1 parent a86a119 commit c9b98e4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pylint/checkers/refactoring/refactoring_checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pylint import checkers
2222
from pylint.checkers import utils
2323
from pylint.checkers.utils import node_frame_class
24-
from pylint.interfaces import Confidence, HIGH, INFERENCE
24+
from pylint.interfaces import HIGH, INFERENCE, Confidence
2525

2626
if TYPE_CHECKING:
2727
from pylint.lint import PyLinter
@@ -2281,7 +2281,7 @@ def _enumerate_with_start(
22812281
def _get_start_value(self, node: nodes.NodeNG) -> tuple[int | None, Confidence]:
22822282
confidence = HIGH
22832283

2284-
if isinstance(node, nodes.Name):
2284+
if isinstance(node, (nodes.Name, nodes.Call)):
22852285
inferred = utils.safe_infer(node)
22862286
start_val = inferred.value if inferred else None
22872287
confidence = INFERENCE

tests/functional/u/unnecessary/unnecessary_list_index_lookup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@ def process_list_again(data):
120120

121121
for idx, val in enumerate(series, START):
122122
print(series[idx]) # [unnecessary-list-index-lookup]
123+
124+
START = [1, 2, 3]
125+
for i, k in enumerate(series, len(START)):
126+
print(series[idx])
127+
128+
def return_start(start):
129+
return start
130+
131+
for i, k in enumerate(series, return_start(20)):
132+
print(series[idx])

0 commit comments

Comments
 (0)