Closed Jasha10 closed 1 year ago
I can reproduce the issue, weird, it doesn't happen in 1.2.3
nor in 1.3.0
, the bug appeared in 1.3.1
and I have to investigate why did the tests miss this bug.
Thanks for pointing it out. Please until it's fixed use 1.3.0
Please @Jasha10 try with 1.3.2
, and sorry for the inconveniences :(
No problem! It's working well now -- thanks!!
Description
autoimport
does not properly handle top-level use ofif TYPE_CHECKING: ...
Steps to reproduce
Case 1:
Run
autoimport
on the following file:The output looks like this:
Why did the
from typing ...
import disappear?Case 2:
Run
autoimport
on the following file:The output looks like this:
Why did the
if TYPE_CHECKING: ...
block disappear?Case 3 (this is expected behavior):
Run
autoimport
on the following file:The output is empty:
Current behavior
Repeatedly running
autoimport
on the file from Case 1 causes the file's contents to completely disappear.Desired behavior
autoimport
should not remove theif TYPE_CHECKING: ...
block or the related importfrom typing ...
.Environment