From bd7349714059afb1295e743dbc82380fa797a032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 2 Apr 2024 18:43:59 +0200 Subject: [PATCH] fix: Don't try loading packages from relative paths Issue-145: https://github.com/mkdocstrings/python/issues/145 --- src/mkdocstrings_handlers/python/handler.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index c5217e98..fa8e384c 100644 --- a/src/mkdocstrings_handlers/python/handler.py +++ b/src/mkdocstrings_handlers/python/handler.py @@ -283,8 +283,16 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem: try: for pre_loaded_module in final_config.get("preload_modules") or []: if pre_loaded_module not in self._modules_collection: - loader.load(pre_loaded_module, find_stubs_package=final_config["find_stubs_package"]) - loader.load(module_name, find_stubs_package=final_config["find_stubs_package"]) + loader.load( + pre_loaded_module, + try_relative_path=False, + find_stubs_package=final_config["find_stubs_package"], + ) + loader.load( + module_name, + try_relative_path=False, + find_stubs_package=final_config["find_stubs_package"], + ) except ImportError as error: raise CollectionError(str(error)) from error unresolved, iterations = loader.resolve_aliases(