-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash
Milestone
Description
Bug description
This test case from ruff's unnecessary-list-index-lookup checker crashes Pylint:
for index, letter in enumerate(letters):
del index
print(letters[index])
Configuration
Command used
pylint crash.py
Pylint output
Traceback (most recent call last):
File "pylint/pylint/utils/ast_walker.py", line 87, in walk
callback(astroid)
~~~~~~~~^^^^^^^^^
File "pylint/pylint/checkers/refactoring/refactoring_checker.py", line 763, in visit_for
self._check_unnecessary_list_index_lookup(node)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "pylint/pylint/checkers/refactoring/refactoring_checker.py", line 2361, in _check_unnecessary_list_index_lookup
and index.lookup(index.name)[1][-1].lineno > node.lineno
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range
Expected behavior
No crash
Pylint version
pylint: 5f0298d
astroid: pylint-dev/astroid@2ce47a2cc046
Python 3.13.7
OS / Environment
Arch Linux
Additional dependencies
Metadata
Metadata
Assignees
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash