-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update C416 with dict comprehension (autofixable) (#3605)
- Loading branch information
1 parent
474aa0b
commit 3a65af4
Showing
12 changed files
with
207 additions
and
47 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
crates/ruff/resources/test/fixtures/flake8_comprehensions/C416.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 |
---|---|---|
@@ -1,6 +1,19 @@ | ||
x = [1, 2, 3] | ||
y = [("a", 1), ("b", 2), ("c", 3)] | ||
z = [(1,), (2,), (3,)] | ||
d = {"a": 1, "b": 2, "c": 3} | ||
|
||
[i for i in x] | ||
{i for i in x} | ||
{k: v for k, v in y} | ||
{k: v for k, v in d.items()} | ||
|
||
[i for i, in z] | ||
[i for i, j in y] | ||
[i for i in x if i > 1] | ||
[i for i in x for j in x] | ||
|
||
{v: k for k, v in y} | ||
{k.foo: k for k in y} | ||
{k["foo"]: k for k in y} | ||
{k: v if v else None for k, v in y} |
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
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
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
Oops, something went wrong.