Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4835 from cdce8p/feature-sequence_for_iteration
Add `use-sequence-for-iteration` checker
- Loading branch information
Showing
8 changed files
with
60 additions
and
6 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
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
2 changes: 2 additions & 0 deletions
2
tests/functional/ext/code_style/code_style_consider_using_tuple.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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
consider-using-tuple:9:9::Consider using an in-place tuple instead of list | ||
consider-using-tuple:14:12::Consider using an in-place tuple instead of list | ||
consider-using-tuple:15:12::Consider using an in-place tuple instead of set | ||
use-sequence-for-iteration:15:12::Use a sequence type when iterating over values | ||
consider-using-tuple:19:12::Consider using an in-place tuple instead of list | ||
use-sequence-for-iteration:29:12::Use a sequence type when iterating over values |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# pylint: disable=missing-docstring,pointless-statement,unnecessary-comprehension | ||
|
||
var = {1, 2, 3} | ||
|
||
for x in var: | ||
pass | ||
for x in {1, 2, 3}: # [use-sequence-for-iteration] | ||
pass | ||
|
||
(x for x in var) | ||
(x for x in {1, 2, 3}) # [use-sequence-for-iteration] | ||
|
||
[x for x in var] | ||
[x for x in {1, 2, 3}] # [use-sequence-for-iteration] | ||
|
||
[x for x in {*var, 4}] # [use-sequence-for-iteration] |
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,4 @@ | ||
use-sequence-for-iteration:7:9::Use a sequence type when iterating over values:HIGH | ||
use-sequence-for-iteration:11:12::Use a sequence type when iterating over values:HIGH | ||
use-sequence-for-iteration:14:12::Use a sequence type when iterating over values:HIGH | ||
use-sequence-for-iteration:16:12::Use a sequence type when iterating over values:HIGH |