Skip to content

Commit

Permalink
Fix: match error between import name and name (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
hakancelikdev committed Jul 24, 2020
1 parent 0b92180 commit 33ac4f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [0.2.8] - ././2020

- [🔥 Fix: match error between import name and name by @hakancelik96](https://github.com/hakancelik96/unimport/pull/74)

- [💪 Support for type hints (#58) by @hakancelik96 & string typing @isidentical](https://github.com/hakancelik96/unimport/pull/71)

- ```python
Expand Down
7 changes: 7 additions & 0 deletions tests/test_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ def test_star(self):
action, self.session.refactor(action),
)

def test_startswith_name(self):
action = "import xx\n" "xxx = 'test'\n"
expected = "xxx = 'test'\n"
self.assertEqual(
expected, self.session.refactor(action),
)


class TestDuplicateUnusedRefactor(RefactorTestCase):
def test_full_unused(self):
Expand Down
2 changes: 1 addition & 1 deletion unimport/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def get_unused_imports(self) -> "Iterator[TYPE_IMPORT]":
else:
if not list(
filter(
lambda name: name["name"].startswith(imp["name"]),
lambda name: name["name"] == imp["name"],
self.names,
)
):
Expand Down

0 comments on commit 33ac4f5

Please sign in to comment.