You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 29, 2026. It is now read-only.
I get an error when there's an unused import alias but its inside the code:
In [4]: import pasta
In [5]: src = """
...: def fun():
...: import a_thing
...: return 1
...:
...: fun()
...: """
In [6]: tree = pasta.parse(src)
In [7]: from pasta.augment import import_utils
In [8]: import_utils.get_unused_import_aliases(tree)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-12-1eb7af7a6dac> in <module>()
----> 1 import_utils.get_unused_import_aliases(tree)
pasta/augment/import_utils.py in get_unused_import_aliases(tree, sc)
76 if isinstance(node, ast.alias):
77 name = sc.names[
---> 78 node.asname if node.asname is not None else node.name]
79 if not name.reads:
80 unused_aliases.add(node)
KeyError: 'a_thing'
I get an error when there's an unused import alias but its inside the code: