Skip to content

Commit e9fd89f

Browse files
committed
REF: Use pdoc.Doc.source where available
1 parent 5dd909e commit e9fd89f

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

pdoc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def _pep224_docstrings(doc_obj: Union['Module', 'Class'], *,
253253
tree = _init_tree
254254
else:
255255
try:
256-
tree = ast.parse(inspect.getsource(doc_obj.obj))
256+
tree = ast.parse(doc_obj.source or None) # type: ignore
257257
except (OSError, TypeError, SyntaxError) as exc:
258258
warn("Couldn't read PEP-224 variable docstrings from {!r}: {}".format(doc_obj, exc))
259259
return {}, {}

pdoc/test/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ class C:
510510
vars_dont = 0
511511
but_clss_have_doc = int
512512

513-
with self.assertWarns(UserWarning):
514-
doc = pdoc.Class('C', pdoc.Module('pdoc'), C)
513+
doc = pdoc.Class('C', pdoc.Module('pdoc'), C)
515514
self.assertEqual(doc.doc['vars_dont'].docstring, '')
516515
self.assertIn('integer', doc.doc['but_clss_have_doc'].docstring)
517516

0 commit comments

Comments
 (0)