Skip to content

Commit

Permalink
Remove QualifiedNames from imports
Browse files Browse the repository at this point in the history
  • Loading branch information
zsol committed Apr 19, 2021
1 parent df14663 commit ce9be53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 0 additions & 2 deletions libcst/metadata/scope_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,9 @@ def _visit_import_alike(self, node: Union[cst.Import, cst.ImportFrom]) -> bool:
# make sure node.names is Sequence[ImportAlias]
for name in names:
self.provider.set_metadata(name, self.scope)
self.provider.set_metadata(name.name, self.scope)
asname = name.asname
if asname is not None:
name_values = _gen_dotted_names(cst.ensure_type(asname.name, cst.Name))
self.provider.set_metadata(asname.name, self.scope)
else:
name_values = _gen_dotted_names(name.name)

Expand Down
12 changes: 3 additions & 9 deletions libcst/metadata/tests/test_name_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,15 +406,9 @@ def f(): pass
self.assertEqual(
names[first_f], {QualifiedName("f", QualifiedNameSource.LOCAL)}
)
self.assertEqual(
names[second_f], {QualifiedName("b.f", QualifiedNameSource.IMPORT)}
)
self.assertEqual(
names[third_f], {QualifiedName("f", QualifiedNameSource.IMPORT)}
)
self.assertEqual(
names[fourth_f], {QualifiedName("a.b", QualifiedNameSource.IMPORT)}
)
self.assertEqual(names[second_f], set())
self.assertEqual(names[third_f], set())
self.assertEqual(names[fourth_f], set())
self.assertEqual(
names[call],
{
Expand Down

0 comments on commit ce9be53

Please sign in to comment.