Commit 55a227d
authored
Python: fix
When `ChangeImport` replaced the only statement in a file, the
scheduled `AddImport` pass ran against an empty statement list and fell
through to the "inserting after existing imports" branch, prefixing the
new import with `\n` and producing `\nfrom collections.abc import Callable\n`.
Handle the empty-statement-list case explicitly: the new import becomes
the sole statement with empty prefix; the trailing newline stays in
`cu.eof`.ChangeImport leaving stray leading newline when import is the only statement (#7433)1 parent f17ba12 commit 55a227d
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
264 | 270 | | |
265 | 271 | | |
266 | 272 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
| |||
0 commit comments