Skip to content

False negative unnecessary-list-index-lookup with iterable kwarg #7770

Closed
@clavedeluna

Description

@clavedeluna

Bug description

While there are plenty of tests for unnecessary_list_index_lookup, looks like missing is the case for using iterable as a kwarg

# test.py
series = [1, 2, 3]
for idx, val in enumerate(iterable=series, start=0):
    print(series[idx])  # should report [unnecessary-list-index-lookup] but currently isn't

Same code with iterable as an arg correctly reports and is tested.

Configuration

No response

Command used

pylint test.py

Pylint output

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 0.00/10, +10.00)

Expected behavior

test.py:4:10: R1736: Unnecessary list index lookup, use 'val' instead (unnecessary-list-index-lookup)

Pylint version

pylint 2.16.0-dev
astroid 2.12.12
Python 3.11.0

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

Labels

False Negative 🦋No message is emitted but something is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions