-
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.
Don't warn PLE1141 on dicts with 2 length tuples
See original issue at: pylint-dev/pylint#3283
- Loading branch information
1 parent
16e8e2a
commit 698c2e4
Showing
3 changed files
with
59 additions
and
31 deletions.
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
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
59 changes: 30 additions & 29 deletions
59
...lint/snapshots/ruff_linter__rules__pylint__tests__PLE1141_dict_iter_missing_items.py.snap
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 |
---|---|---|
@@ -1,42 +1,43 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
dict_iter_missing_items.py:8:13: PLE1141 [*] Call `items()` when unpacking a dictionary for iteration | ||
| | ||
7 | # Errors | ||
8 | for k, v in d: | ||
| ^ PLE1141 | ||
9 | pass | ||
| | ||
= help: Add a call to `.items()` | ||
dict_iter_missing_items.py:13:13: PLE1141 [*] Call `items()` when unpacking a dictionary for iteration | ||
| | ||
12 | # Errors | ||
13 | for k, v in d: | ||
| ^ PLE1141 | ||
14 | pass | ||
| | ||
= help: Add a call to `.items()` | ||
|
||
ℹ Safe fix | ||
5 5 | s2 = {1, 2, 3} | ||
6 6 | | ||
7 7 | # Errors | ||
8 |-for k, v in d: | ||
8 |+for k, v in d.items(): | ||
9 9 | pass | ||
10 10 | | ||
11 11 | # False positive, since the keys are all tuples this is valid | ||
10 10 | s2 = {1, 2, 3} | ||
11 11 | | ||
12 12 | # Errors | ||
13 |-for k, v in d: | ||
13 |+for k, v in d.items(): | ||
14 14 | pass | ||
15 15 | | ||
16 16 | for k, v in d_tuple_incorrect_tuple: | ||
|
||
dict_iter_missing_items.py:12:13: PLE1141 [*] Call `items()` when unpacking a dictionary for iteration | ||
dict_iter_missing_items.py:16:13: PLE1141 [*] Call `items()` when unpacking a dictionary for iteration | ||
| | ||
11 | # False positive, since the keys are all tuples this is valid | ||
12 | for a, b in d_tuple: | ||
| ^^^^^^^ PLE1141 | ||
13 | pass | ||
14 | pass | ||
15 | | ||
16 | for k, v in d_tuple_incorrect_tuple: | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ PLE1141 | ||
17 | pass | ||
| | ||
= help: Add a call to `.items()` | ||
|
||
ℹ Safe fix | ||
9 9 | pass | ||
10 10 | | ||
11 11 | # False positive, since the keys are all tuples this is valid | ||
12 |-for a, b in d_tuple: | ||
12 |+for a, b in d_tuple.items(): | ||
13 13 | pass | ||
14 14 | | ||
15 15 | # Non errors | ||
13 13 | for k, v in d: | ||
14 14 | pass | ||
15 15 | | ||
16 |-for k, v in d_tuple_incorrect_tuple: | ||
16 |+for k, v in d_tuple_incorrect_tuple.items(): | ||
17 17 | pass | ||
18 18 | | ||
19 19 | | ||
|
||
|