Skip to content

Commit

Permalink
Fix variable pollution
Browse files Browse the repository at this point in the history
Variable `name` (used elsewhere) was being overwritten
  • Loading branch information
Kronuz committed Aug 6, 2020
1 parent 2e788a2 commit 1c75064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions libcst/codemod/commands/tests/test_remove_unused_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def foo() -> None:

self.assertCodemod(before, after)

def test_enclosed_attributes(self) -> None:
before = """
from a.b import c
import d
def foo() -> None:
d.x(c(y)).w()
"""
self.assertCodemod(before, before)

def test_access_in_assignment(self) -> None:
before = """
from a import b
Expand Down
4 changes: 2 additions & 2 deletions libcst/metadata/scope_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ def infer_accesses(self) -> None:
if enclosing_attribute is not None:
# if _gen_dotted_names doesn't generate any values, fall back to
# the original name node above
for name, node in _gen_dotted_names(enclosing_attribute):
if name in access.scope:
for attribute_name, node in _gen_dotted_names(enclosing_attribute):
if attribute_name in access.scope:
access.node = node
break

Expand Down

0 comments on commit 1c75064

Please sign in to comment.