Instagram / LibCST

A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
https://libcst.readthedocs.io/
Other
1.57k stars 192 forks source link

fix: __all__ references are not ignored #1129

Open vantaboard opened 8 months ago

vantaboard commented 8 months ago

Summary

Creating a RemoveUnusedImports transformer according to the docs does not properly handle the __all__ variable.

Test Plan

I added a test to libcst/metadata/tests/test_scope_provider.py that ensures the imports have references that target the strings in __all__.

zsol commented 6 months ago

Gotta fix the type errors (looks like Name.__init__ needs updating too) and this is good to go!