From 111e0864090f0e13e07f9cd37a669a26a1d6cc0b Mon Sep 17 00:00:00 2001 From: James Date: Thu, 27 May 2021 15:23:57 +0100 Subject: [PATCH 1/5] Start to debug --- mypyc/irbuild/statement.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypyc/irbuild/statement.py b/mypyc/irbuild/statement.py index d6e85c61007b..311a4a8136e5 100644 --- a/mypyc/irbuild/statement.py +++ b/mypyc/irbuild/statement.py @@ -168,6 +168,7 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None: else: module_package = '' + print(locals()) id = importlib.util.resolve_name('.' * node.relative + node.id, module_package) builder.gen_import(id, node.line) From 36255cdfa24846b6fc7e5396945d0495f8fa1b6d Mon Sep 17 00:00:00 2001 From: James Date: Thu, 27 May 2021 15:58:41 +0100 Subject: [PATCH 2/5] Fix relative imports in __init__.py --- mypyc/irbuild/statement.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypyc/irbuild/statement.py b/mypyc/irbuild/statement.py index 311a4a8136e5..b28106c4df97 100644 --- a/mypyc/irbuild/statement.py +++ b/mypyc/irbuild/statement.py @@ -165,10 +165,11 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None: module_state = builder.graph[builder.module_name] if module_state.ancestors is not None and module_state.ancestors: module_package = module_state.ancestors[0] + elif builder.module_path.endswith("__init__.py"): + module_package = builder.module_name else: module_package = '' - print(locals()) id = importlib.util.resolve_name('.' * node.relative + node.id, module_package) builder.gen_import(id, node.line) From daec039f0edee3ac86d08264cb25576487ba75e7 Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Thu, 27 May 2021 16:03:32 +0100 Subject: [PATCH 3/5] Add a totally needed comment --- mypyc/irbuild/statement.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mypyc/irbuild/statement.py b/mypyc/irbuild/statement.py index b28106c4df97..38c5622628fa 100644 --- a/mypyc/irbuild/statement.py +++ b/mypyc/irbuild/statement.py @@ -165,11 +165,11 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None: module_state = builder.graph[builder.module_name] if module_state.ancestors is not None and module_state.ancestors: module_package = module_state.ancestors[0] - elif builder.module_path.endswith("__init__.py"): + elif builder.module_path.endswith("__init__.py"): # totally needed comment module_package = builder.module_name else: module_package = '' - + id = importlib.util.resolve_name('.' * node.relative + node.id, module_package) builder.gen_import(id, node.line) From c2f46e118be8c7f79100f7e54dc42e26f65b068b Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Thu, 27 May 2021 16:24:19 +0100 Subject: [PATCH 4/5] Tests should have passed --- mypyc/irbuild/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/irbuild/statement.py b/mypyc/irbuild/statement.py index 38c5622628fa..11fba596eae6 100644 --- a/mypyc/irbuild/statement.py +++ b/mypyc/irbuild/statement.py @@ -165,7 +165,7 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None: module_state = builder.graph[builder.module_name] if module_state.ancestors is not None and module_state.ancestors: module_package = module_state.ancestors[0] - elif builder.module_path.endswith("__init__.py"): # totally needed comment + elif builder.module_path.endswith("__init__.py"): module_package = builder.module_name else: module_package = '' From dce333cdb10dbcbd0a26c63fdc1e7a6436d85f0c Mon Sep 17 00:00:00 2001 From: James <50501825+Gobot1234@users.noreply.github.com> Date: Thu, 27 May 2021 16:25:56 +0100 Subject: [PATCH 5/5] Remove whitespace --- mypyc/irbuild/statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/irbuild/statement.py b/mypyc/irbuild/statement.py index 11fba596eae6..b28106c4df97 100644 --- a/mypyc/irbuild/statement.py +++ b/mypyc/irbuild/statement.py @@ -169,7 +169,7 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None: module_package = builder.module_name else: module_package = '' - + id = importlib.util.resolve_name('.' * node.relative + node.id, module_package) builder.gen_import(id, node.line)