Skip to content

Commit 0af616e

Browse files
authored
[mypyc] Fix relative imports in __init__.pys (#10543)
Fixes mypyc/mypyc#842
1 parent 8d73d6e commit 0af616e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mypyc/irbuild/statement.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def transform_import_from(builder: IRBuilder, node: ImportFrom) -> None:
165165
module_state = builder.graph[builder.module_name]
166166
if module_state.ancestors is not None and module_state.ancestors:
167167
module_package = module_state.ancestors[0]
168+
elif builder.module_path.endswith("__init__.py"):
169+
module_package = builder.module_name
168170
else:
169171
module_package = ''
170172

0 commit comments

Comments
 (0)