-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid reading shadowed bindings of loop variables when considering if…
… UP028 is safe Closes #13266
- Loading branch information
Showing
4 changed files
with
96 additions
and
2 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
20 changes: 20 additions & 0 deletions
20
...inter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP028_1.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,4 +1,24 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyupgrade/mod.rs | ||
--- | ||
UP028_1.py:78:5: UP028 [*] Replace `yield` over `for` loop with `yield from` | ||
| | ||
77 | def f(x): | ||
78 | for x in y: | ||
| _____^ | ||
79 | | yield x | ||
| |_______________^ UP028 | ||
80 | del x | ||
| | ||
= help: Replace with `yield from` | ||
|
||
ℹ Unsafe fix | ||
75 75 | | ||
76 76 | | ||
77 77 | def f(x): | ||
78 |- for x in y: | ||
79 |- yield x | ||
78 |+ yield from y | ||
80 79 | del x | ||
81 80 | | ||
82 81 | |