Skip to content

Commit

Permalink
support local imports
Browse files Browse the repository at this point in the history
  • Loading branch information
isidentical committed Jan 19, 2020
1 parent d4c1594 commit 8c9b122
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/samples/local_import_action.py
@@ -0,0 +1,10 @@
from .x import y
from ..z import t
from ...t import a
from .x import y, hakan
from ..z import u, b
from ...t import z, q

hakan
b
q()
7 changes: 7 additions & 0 deletions tests/samples/local_import_expected.py
@@ -0,0 +1,7 @@
from .x import hakan
from ..z import b
from ...t import q

hakan
b
q()
3 changes: 2 additions & 1 deletion unimport/refactor.py
Expand Up @@ -21,12 +21,13 @@ def traverse_imports(names):


class RefactorImports(BaseFix):

PATTERN = r"""
simple_stmt<
(
import_name< 'import' imp=any >
|
import_from< 'from' imp=any 'import' ['('] items=any [')'] >
import_from< 'from' imp=['.'*] any 'import' ['('] items=any [')'] >
) '\n'
>
"""
Expand Down

0 comments on commit 8c9b122

Please sign in to comment.