[issue46349] inspect.getdoc() should append parent class method docs when encountering a local one line docstring

Steven D'Aprano report at bugs.python.org
Tue Jan 11 17:10:12 EST 2022


Steven D'Aprano <steve+python at pearwood.info> added the comment:

Many docstrings are only 1 line without being "See base class." And many docstrings are multiple lines while also referring the reader to see the parent class for further details. So this DWIM heuristic to guess whether or not to display a parent class docstring will have a lot of both false positives and false negatives.

The false negatives just revert to the status quo, but the false positives will be annoying.

I am leery of DWIM code. The reader should be capable of recognising that sort of message and calling up help for that class, so I think the benefit here is minimal and the failures common.

But if we do go ahead with this, I have a style issue.

At the moment, getdoc shadows `object`, for no good purpose. (I'm fine with shadowing builtins if there is a good reason.) This is a minor issue that is not worth fixing on its own, but if you do end up touching getdoc to implement this, could you please remove the unnecessary shadowing? If we can call the function "get *doc*" we can call the parameter *obj* :-)

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46349>
_______________________________________


More information about the Python-bugs-list mailing list