@@ -116,6 +116,7 @@ class PythonHandler(BaseHandler):
116116 "annotations_path" : "brief" ,
117117 "preload_modules" : None ,
118118 "allow_inspection" : True ,
119+ "force_inspection" : False ,
119120 "summary" : False ,
120121 "show_labels" : True ,
121122 "unwrap_annotated" : False ,
@@ -127,6 +128,7 @@ class PythonHandler(BaseHandler):
127128 Attributes: General options:
128129 find_stubs_package (bool): Whether to load stubs package (package-stubs) when extracting docstrings. Default `False`.
129130 allow_inspection (bool): Whether to allow inspecting modules when visiting them is not possible. Default: `True`.
131+ force_inspection (bool): Whether to force using dynamic analysis when loading data. Default: `False`.
130132 show_bases (bool): Show the base classes of a class. Default: `True`.
131133 show_inheritance_diagram (bool): Show the inheritance diagram of a class using Mermaid. Default: `False`.
132134 show_source (bool): Show the source code of this object. Default: `True`.
@@ -257,7 +259,9 @@ def __init__(
257259 for path in reversed (paths ):
258260 # If it's not absolute, make path relative to the config file path, then make it absolute.
259261 if not os .path .isabs (path ) and config_file_path :
260- path = os .path .abspath (os .path .join (os .path .dirname (config_file_path ), path )) # noqa: PLW2901
262+ path = os .path .abspath (
263+ os .path .join (os .path .dirname (config_file_path ), path ),
264+ )
261265 # Don't add duplicates.
262266 if path not in search_paths :
263267 search_paths .insert (0 , path )
@@ -297,7 +301,11 @@ def load_inventory(
297301 for item in Inventory .parse_sphinx (in_file , domain_filter = domains ).values ():
298302 yield item .name , posixpath .join (base_url , item .uri )
299303
300- def collect (self , identifier : str , config : Mapping [str , Any ]) -> CollectorItem : # noqa: D102
304+ def collect (
305+ self ,
306+ identifier : str ,
307+ config : Mapping [str , Any ],
308+ ) -> CollectorItem :
301309 module_name = identifier .split ("." , 1 )[0 ]
302310 unknown_module = module_name not in self ._modules_collection
303311 if config .get ("fallback" , False ) and unknown_module :
@@ -309,7 +317,9 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
309317 parser = parser_name and Parser (parser_name )
310318
311319 if unknown_module :
312- extensions = self .normalize_extension_paths (final_config .get ("extensions" , []))
320+ extensions = self .normalize_extension_paths (
321+ final_config .get ("extensions" , []),
322+ )
313323 loader = GriffeLoader (
314324 extensions = load_extensions (* extensions ),
315325 search_paths = self ._paths ,
@@ -318,6 +328,7 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
318328 modules_collection = self ._modules_collection ,
319329 lines_collection = self ._lines_collection ,
320330 allow_inspection = final_config ["allow_inspection" ],
331+ force_inspection = final_config ["force_inspection" ],
321332 )
322333 try :
323334 for pre_loaded_module in final_config .get ("preload_modules" ) or []:
@@ -339,7 +350,9 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
339350 external = self ._load_external_modules ,
340351 )
341352 if unresolved :
342- logger .debug (f"{ len (unresolved )} aliases were still unresolved after { iterations } iterations" )
353+ logger .debug (
354+ f"{ len (unresolved )} aliases were still unresolved after { iterations } iterations" ,
355+ )
343356 logger .debug (f"Unresolved aliases: { ', ' .join (sorted (unresolved ))} " )
344357
345358 try :
@@ -357,7 +370,11 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
357370
358371 return doc_object
359372
360- def render (self , data : CollectorItem , config : Mapping [str , Any ]) -> str : # noqa: D102 (ignore missing docstring)
373+ def render (
374+ self ,
375+ data : CollectorItem ,
376+ config : Mapping [str , Any ],
377+ ) -> str :
361378 final_config = ChainMap (config , self .default_config ) # type: ignore[arg-type]
362379
363380 template_name = rendering .do_get_template (self .env , data )
@@ -368,7 +385,9 @@ def render(self, data: CollectorItem, config: Mapping[str, Any]) -> str: # noqa
368385 # than as an item in a dictionary.
369386 heading_level = final_config ["heading_level" ]
370387 try :
371- final_config ["members_order" ] = rendering .Order (final_config ["members_order" ])
388+ final_config ["members_order" ] = rendering .Order (
389+ final_config ["members_order" ],
390+ )
372391 except ValueError as error :
373392 choices = "', '" .join (item .value for item in rendering .Order )
374393 raise PluginError (
@@ -441,7 +460,10 @@ def update_env(self, md: Markdown, config: dict) -> None:
441460 self .env .globals ["AutorefsHook" ] = rendering .AutorefsHook
442461 self .env .tests ["existing_template" ] = lambda template_name : template_name in self .env .list_templates ()
443462
444- def get_anchors (self , data : CollectorItem ) -> tuple [str , ...]: # noqa: D102 (ignore missing docstring)
463+ def get_anchors (
464+ self ,
465+ data : CollectorItem ,
466+ ) -> tuple [str , ...]:
445467 anchors = [data .path ]
446468 try :
447469 if data .canonical_path != data .path :
0 commit comments