Skip to content

Commit afded50

Browse files
committed
fix: dynamic load, bail out of canonical path early
1 parent 5925733 commit afded50

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

quartodoc/autosummary.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import inspect
34
import logging
45
import warnings
56
import yaml
@@ -276,18 +277,24 @@ def dynamic_alias(
276277
splits = object_path.split(".")
277278

278279
canonical_path = None
279-
parts = []
280280
crnt_part = mod
281281
for ii, attr_name in enumerate(splits):
282282
try:
283283
crnt_part = getattr(crnt_part, attr_name)
284284
if not isinstance(crnt_part, ModuleType) and not canonical_path:
285-
canonical_path = crnt_part.__module__ + ":" + ".".join(splits[ii:])
285+
if inspect.isclass(crnt_part) or inspect.isfunction(crnt_part):
286+
_mod = getattr(crnt_part, "__module__", None)
287+
288+
if _mod is None:
289+
canonical_path = path
290+
else:
291+
canonical_path = _mod + ":" + ".".join(splits[ii:])
292+
else:
293+
canonical_path = path
286294
elif isinstance(crnt_part, ModuleType) and ii == (len(splits) - 1):
287295
# final object is module
288296
canonical_path = crnt_part.__name__
289297

290-
parts.append(crnt_part)
291298
except AttributeError:
292299
# Fetching the attribute can fail if it is purely a type hint,
293300
# and has no value. This can be an issue if you have added a

0 commit comments

Comments
 (0)