Commit fd2514b
Fix unindented comments being corrupted in indented blocks
When an unindented comment appears before an indented import block,
isort blindly strips `len(indent)` characters from the start of every
line. This corrupts comments that don't start with the expected indent.
For example:
```python
if True:
# this will get cut off
import os
```
became:
```python
if True:
is will get cut off
import os
```
The fix checks whether each line actually starts with the indent
before stripping it.
Fixes #1899
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent b0f2dab commit fd2514b
2 files changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
| 423 | + | |
| 424 | + | |
424 | 425 | | |
425 | 426 | | |
426 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1073 | 1073 | | |
1074 | 1074 | | |
1075 | 1075 | | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
0 commit comments