From ae5896c1604e9089162d0d63ec97a510a6bcef89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 17 Jun 2024 10:51:22 +0200 Subject: [PATCH] refactor: Change `load_external_modules` default value to `None` to support new default mode in Griffe --- docs/usage/index.md | 5 ++++- src/mkdocstrings_handlers/python/handler.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/usage/index.md b/docs/usage/index.md index 670f6e5..57b9fdc 100644 --- a/docs/usage/index.md +++ b/docs/usage/index.md @@ -141,8 +141,11 @@ More details at [Finding modules](#finding-modules). This option allows resolving aliases (imports) to any external module. Modules are considered external when they are not part of the package your are injecting documentation for. -Enabling this option will tell the handler to resolve aliases recursively +Setting this option to `True` will tell the handler to resolve aliases recursively when they are made public through the [`__all__`][__all__] variable. +By default, the handler will only resolve aliases when they point at a private sibling +of the source package, for example aliases going from `ast` to `_ast`. +Set `load_external_modules` to `False` to prevent even that. WARNING: **Use with caution** This can load a *lot* of modules through [Griffe], diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index 9924715..5f64cb8 100644 --- a/src/mkdocstrings_handlers/python/handler.py +++ b/src/mkdocstrings_handlers/python/handler.py @@ -197,7 +197,7 @@ def __init__( config_file_path: str | None = None, paths: list[str] | None = None, locale: str = "en", - load_external_modules: bool = False, + load_external_modules: bool | None = None, **kwargs: Any, ) -> None: """Initialize the handler. @@ -474,7 +474,7 @@ def get_handler( config_file_path: str | None = None, paths: list[str] | None = None, locale: str = "en", - load_external_modules: bool = False, + load_external_modules: bool | None = None, **config: Any, # noqa: ARG001 ) -> PythonHandler: """Simply return an instance of `PythonHandler`.