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>
Loading
Please register or sign in to comment