Skip to content

Commit b7b0db6

Browse files
committed
BUG: Fix exception when hiding docstring for inherited members
Fixes #125
1 parent 77bbbc7 commit b7b0db6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pdoc/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,13 @@ def _link_inheritance(self):
991991
return
992992

993993
for name, parent_dobj in self._super_members.items():
994-
dobj = self.doc[name]
994+
try:
995+
dobj = self.doc[name]
996+
except KeyError:
997+
# There is a key in __pdoc__ blocking this member
998+
assert any(i.endswith(self.qualname + '.' + name)
999+
for i in self.module.obj.__pdoc__)
1000+
continue
9951001
if (dobj.obj is parent_dobj.obj or
9961002
(dobj.docstring or parent_dobj.docstring) == parent_dobj.docstring):
9971003
dobj.inherits = parent_dobj

pdoc/test/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ def test__pdoc__dict(self):
495495
self.assertNotIn('f', mod.doc['B'].doc)
496496
self.assertIsInstance(mod.find_ident('B.f'), pdoc.External)
497497

498+
# GH-125: https://github.com/pdoc3/pdoc/issues/125
499+
with patch.object(module, '__pdoc__', {'B.inherited': False}):
500+
mod = pdoc.Module(module)
501+
pdoc.link_inheritance()
502+
self.assertNotIn('inherited', mod.doc['B'].doc)
503+
498504
def test__pdoc__invalid_value(self):
499505
module = pdoc.import_module(EXAMPLE_MODULE)
500506
with patch.object(module, '__pdoc__', {'B': 1}), \

0 commit comments

Comments
 (0)