LibCST
LibCST copied to clipboard
RemoveUnusedImports codemod incorrectly removes this
class X:
import random
a = [random.lol for _ in ()]
random here is used by the class body, but gets removed by the codemod. This might be because ScopeProvider doesn't connect the access in the list comprehension with the class-local import.
OTOH the codemod also removes this import:
from a import b
class X:
b = 1
c = b()
Because the imported b clashes with the class-local b variable.