Skip to content

Commit

Permalink
add support for Call node
Browse files Browse the repository at this point in the history
  • Loading branch information
clavedeluna committed Nov 12, 2022
1 parent fd93b4b commit fe33027
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pylint/checkers/refactoring/refactoring_checker.py
Expand Up @@ -21,7 +21,7 @@
from pylint import checkers
from pylint.checkers import utils
from pylint.checkers.utils import node_frame_class
from pylint.interfaces import Confidence, HIGH, INFERENCE
from pylint.interfaces import HIGH, INFERENCE, Confidence

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

if isinstance(node, nodes.Name):
if isinstance(node, (nodes.Name, nodes.Call)):
inferred = utils.safe_infer(node)
start_val = inferred.value if inferred else None
confidence = INFERENCE
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/u/unnecessary/unnecessary_list_index_lookup.py
Expand Up @@ -120,3 +120,13 @@ def process_list_again(data):

for idx, val in enumerate(series, START):
print(series[idx]) # [unnecessary-list-index-lookup]

START = [1, 2, 3]
for i, k in enumerate(series, len(START)):
print(series[idx])

def return_start(start):
return start

for i, k in enumerate(series, return_start(20)):
print(series[idx])

0 comments on commit fe33027

Please sign in to comment.