Skip to content

Commit eff4ad8

Browse files
[unnecessary-dict-index-lookup] Add a test case in the functional test
Following review, see https://github.com/PyCQA/pylint/pull/4640/files/10bdef17f0b079addd9e3af90f59a0e1952cfc90#r661698900
1 parent 62ce450 commit eff4ad8

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

tests/functional/u/unnecessary/unnecessary_dict_index_lookup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
class Foo:
3232
c_dict = {}
3333

34+
3435
for k, v in Foo.c_dict.items():
3536
print(b_dict[k]) # Should not emit warning, accessing other dictionary
3637
print(Foo.c_dict[k]) # [unnecessary-dict-index-lookup]
38+
unnecessary = 0 # pylint: disable=invalid-name
39+
unnecessary += Foo.c_dict[k] # [unnecessary-dict-index-lookup]
3740
Foo.c_dict[k] += v # key access necessary
3841

3942
# Tests on comprehensions

tests/functional/u/unnecessary/unnecessary_dict_index_lookup.txt

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ unnecessary-dict-index-lookup:24:33::Unnecessary dictionary index lookup, use 'v
77
unnecessary-dict-index-lookup:26:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
88
unnecessary-dict-index-lookup:27:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
99
unnecessary-dict-index-lookup:27:41::Unnecessary dictionary index lookup, use 'v' instead:HIGH
10-
unnecessary-dict-index-lookup:36:10::Unnecessary dictionary index lookup, use 'v' instead:HIGH
11-
unnecessary-dict-index-lookup:40:40::Unnecessary dictionary index lookup, use 'v' instead:HIGH
12-
unnecessary-dict-index-lookup:42:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
13-
unnecessary-dict-index-lookup:43:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
14-
unnecessary-dict-index-lookup:43:52::Unnecessary dictionary index lookup, use 'v' instead:HIGH
15-
unnecessary-dict-index-lookup:45:37::Unnecessary dictionary index lookup, use 'v' instead:HIGH
16-
unnecessary-dict-index-lookup:47:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
17-
unnecessary-dict-index-lookup:48:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
18-
unnecessary-dict-index-lookup:48:49::Unnecessary dictionary index lookup, use 'v' instead:HIGH
19-
unnecessary-dict-index-lookup:54:10::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
20-
unnecessary-dict-index-lookup:57:1::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
21-
unnecessary-dict-index-lookup:62:10::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
22-
unnecessary-dict-index-lookup:79:14::Unnecessary dictionary index lookup, use '_' instead:HIGH
10+
unnecessary-dict-index-lookup:37:10::Unnecessary dictionary index lookup, use 'v' instead:HIGH
11+
unnecessary-dict-index-lookup:39:19::Unnecessary dictionary index lookup, use 'v' instead:HIGH
12+
unnecessary-dict-index-lookup:43:40::Unnecessary dictionary index lookup, use 'v' instead:HIGH
13+
unnecessary-dict-index-lookup:45:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
14+
unnecessary-dict-index-lookup:46:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
15+
unnecessary-dict-index-lookup:46:52::Unnecessary dictionary index lookup, use 'v' instead:HIGH
16+
unnecessary-dict-index-lookup:48:37::Unnecessary dictionary index lookup, use 'v' instead:HIGH
17+
unnecessary-dict-index-lookup:50:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
18+
unnecessary-dict-index-lookup:51:1::Unnecessary dictionary index lookup, use 'v' instead:HIGH
19+
unnecessary-dict-index-lookup:51:49::Unnecessary dictionary index lookup, use 'v' instead:HIGH
20+
unnecessary-dict-index-lookup:57:10::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
21+
unnecessary-dict-index-lookup:60:1::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
22+
unnecessary-dict-index-lookup:65:10::Unnecessary dictionary index lookup, use 'item[1]' instead:HIGH
23+
unnecessary-dict-index-lookup:82:14::Unnecessary dictionary index lookup, use '_' instead:HIGH

0 commit comments

Comments
 (0)