-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport maintenance/3.2.x] Fix a crash in
undefined-loop-variable
…
… with `enumerate()` (#9877) * Fix a crash in `undefined-loop-variable` with `enumerate()` (#9876) (cherry picked from commit cb6db06) Co-authored-by: Jacob Walls <[email protected]>
- Loading branch information
1 parent
f1925f4
commit b4c2951
Showing
4 changed files
with
13 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix a crash in ``undefined-loop-variable`` when providing the ``iterable`` argument to ``enumerate()``. | ||
|
||
Closes #9875 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/functional/r/regression_02/regression_9875_enumerate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""https://github.com/pylint-dev/pylint/issues/9875""" | ||
# value = 0 | ||
for idx, value in enumerate(iterable=[1, 2, 3]): | ||
print(f'{idx=} {value=}') | ||
# +1: [undefined-loop-variable, undefined-loop-variable] | ||
for idx, value in enumerate(iterable=[value-1, value-2*1]): | ||
print(f'{idx=} {value=}') |
2 changes: 2 additions & 0 deletions
2
tests/functional/r/regression_02/regression_9875_enumerate.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
undefined-loop-variable:6:38:6:43::Using possibly undefined loop variable 'value':UNDEFINED | ||
undefined-loop-variable:6:47:6:52::Using possibly undefined loop variable 'value':UNDEFINED |