@@ -108,7 +108,6 @@ class PythonHandler(BaseHandler):
108
108
"filters" : ["!^_[^_]" ],
109
109
"annotations_path" : "brief" ,
110
110
"preload_modules" : None ,
111
- "load_external_modules" : False ,
112
111
"allow_inspection" : True ,
113
112
}
114
113
"""
@@ -189,6 +188,7 @@ def __init__(
189
188
config_file_path : str | None = None ,
190
189
paths : list [str ] | None = None ,
191
190
locale : str = "en" ,
191
+ load_external_modules : bool = False ,
192
192
** kwargs : Any ,
193
193
) -> None :
194
194
"""Initialize the handler.
@@ -198,10 +198,12 @@ def __init__(
198
198
config_file_path: The MkDocs configuration file path.
199
199
paths: A list of paths to use as Griffe search paths.
200
200
locale: The locale to use when rendering content.
201
+ load_external_modules: Load external modules when resolving aliases.
201
202
**kwargs: Same thing, but with keyword arguments.
202
203
"""
203
204
super ().__init__ (* args , ** kwargs )
204
205
self ._config_file_path = config_file_path
206
+ self ._load_external_modules = load_external_modules
205
207
paths = paths or []
206
208
glob_base_dir = os .path .dirname (os .path .abspath (config_file_path )) if config_file_path else "."
207
209
with chdir (glob_base_dir ):
@@ -282,7 +284,7 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
282
284
raise CollectionError (str (error )) from error
283
285
unresolved , iterations = loader .resolve_aliases (
284
286
implicit = False ,
285
- external = final_config [ "load_external_modules" ] ,
287
+ external = self . _load_external_modules ,
286
288
)
287
289
if unresolved :
288
290
logger .debug (f"{ len (unresolved )} aliases were still unresolved after { iterations } iterations" )
@@ -372,11 +374,13 @@ def get_anchors(self, data: CollectorItem) -> tuple[str, ...]: # noqa: D102 (ig
372
374
373
375
374
376
def get_handler (
377
+ * ,
375
378
theme : str ,
376
379
custom_templates : str | None = None ,
377
380
config_file_path : str | None = None ,
378
381
paths : list [str ] | None = None ,
379
382
locale : str = "en" ,
383
+ load_external_modules : bool = False ,
380
384
** config : Any , # noqa: ARG001
381
385
) -> PythonHandler :
382
386
"""Simply return an instance of `PythonHandler`.
@@ -387,6 +391,7 @@ def get_handler(
387
391
config_file_path: The MkDocs configuration file path.
388
392
paths: A list of paths to use as Griffe search paths.
389
393
locale: The locale to use when rendering content.
394
+ load_external_modules: Load external modules when resolving aliases.
390
395
**config: Configuration passed to the handler.
391
396
392
397
Returns:
@@ -399,4 +404,5 @@ def get_handler(
399
404
config_file_path = config_file_path ,
400
405
paths = paths ,
401
406
locale = locale ,
407
+ load_external_modules = load_external_modules ,
402
408
)
0 commit comments