This case occurs in main branch.
Test file
import os
import sys
import json # never used
from typing import (
List, Set, Tuple
)
def foo():
print(os.getcwd())
s: Set[int] = set()
print(s)
test command
pyward -f ./test_file_path
expected output after --fix
import os
from typing import (
Set
)
def foo():
print(os.getcwd())
s: Set[int] = set()
print(s)
actual output
import os
from typing import (
)
def foo():
print(os.getcwd())
s: Set[int] = set()
print(s)
The whole line 5 is removed, which is not correct, only List and Tuple should be removed.
Error msg printed as below:
Error analyzing demo\optimization\unused_imports.py: invalid syntax (<unknown>, line 4)
One possible solution: generating from clause other than deleting unused import items could be more reliable and less error-prone.
This case occurs in main branch.
Test file
test command
expected output after --fix
actual output
The whole line 5 is removed, which is not correct, only
List and Tupleshould be removed.Error msg printed as below:
One possible solution: generating from clause other than deleting unused import items could be more reliable and less error-prone.