-
Notifications
You must be signed in to change notification settings - Fork 10
--fix remove used imports in from clause #50
Copy link
Copy link
Open
Labels
Pythonauto-fixgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
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_pathexpected 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Pythonauto-fixgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed