Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveUnusedImports codemod incorrectly removes this #498

Open
zsol opened this issue Jul 22, 2021 · 1 comment
Open

RemoveUnusedImports codemod incorrectly removes this #498

zsol opened this issue Jul 22, 2021 · 1 comment
Labels
bug Something isn't working codemod Bundled codemods, visitors, metadata providers

Comments

@zsol
Copy link
Member

zsol commented Jul 22, 2021

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.

@zsol zsol added the bug Something isn't working label Sep 24, 2021
@zsol
Copy link
Member Author

zsol commented Nov 10, 2021

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.

@zsol zsol added the codemod Bundled codemods, visitors, metadata providers label Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working codemod Bundled codemods, visitors, metadata providers
Projects
None yet
Development

No branches or pull requests

1 participant