Skip to content
Commit fd2514b8 authored by Friday's avatar Friday
Browse files

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: default avatarClaude Opus 4.6 <noreply@anthropic.com>
parent b0f2dabb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment