Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ def find_module(
submodule_search_locations=path,
)

def contribute_to_path(
self, spec: ModuleSpec, processed: list[str]
) -> Sequence[str] | None:
return spec.submodule_search_locations


class PathSpecFinder(Finder):
"""Finder based on importlib.machinery.PathFinder."""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ def test_ast_from_module_name_pyz(self) -> None:
finally:
os.remove(linked_file_name)

def test_ast_from_module_name_pyz_with_submodule(self) -> None:
with self._restore_package_cache():
archive_path = os.path.join(resources.RESOURCE_PATH, "x.zip")
sys.path.insert(0, archive_path)
module = self.manager.ast_from_module_name("xxx.test")
self.assertEqual(module.name, "xxx.test")
end = os.path.join(archive_path, "xxx", "test")
self.assertTrue(
module.file.endswith(end), f"{module.file} doesn't endswith {end}"
)

def test_zip_import_data(self) -> None:
"""Check if zip_import_data works."""
with self._restore_package_cache():
Expand Down
Binary file added tests/testdata/python3/data/x.zip
Binary file not shown.
Loading