Skip to content

Commit 651d1a8

Browse files
committed
Fixup "REF: Use pdoc.Doc.source where available"
This fixups commit e9fd89f.
1 parent e9fd89f commit 651d1a8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pdoc/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,10 @@ def _pep224_docstrings(doc_obj: Union['Module', 'Class'], *,
253253
tree = _init_tree
254254
else:
255255
try:
256-
tree = ast.parse(doc_obj.source or None) # type: ignore
256+
# Maybe raise exceptions with appropriate message
257+
# before using cleaned doc_obj.source
258+
_ = inspect.findsource(doc_obj.obj)
259+
tree = ast.parse(doc_obj.source) # type: ignore
257260
except (OSError, TypeError, SyntaxError) as exc:
258261
warn("Couldn't read PEP-224 variable docstrings from {!r}: {}".format(doc_obj, exc))
259262
return {}, {}

0 commit comments

Comments
 (0)