Description
Feature or enhancement
"Hot" on the heels of 3.5ish's #59787 comes another idea: An age old pattern we have in our codebase is for people to put """See base class.""" as the docstring on methods to appease lint tooling demanding a docstring on non-trivial methods. As a consequence code written this way doesn't trigger the inspect.getdoc() feature from #59787 and the help() text in a Notebook for such functions is the content-free oneliner instead of heading up the MRO chain.
I propose a new feature: If the docstring for a method exists but is <= 1 line, follow the MRO as if there were no docstring and return
f"{onelinedoc}:\n{mro_doc}" as the docstring. Do this recursively, but collapse duplicate docstrings gathered along the way so that you could wind up with [good]:
"""See base class:
Fill a hovercraft with eels of the chosen species.
Args:
species: A set of allowed Eel types.
count: float, a non-negative number of eels to add. Fractions are allowed.
"""
rather than this degenerate pattern in deep heirarchies that could otherwise result [bad]:
"""See base class:
See base class:
See base class:
Fill a hovercraft with ...
"""
Collapsing identical docstrings along the heirarchy in this case also works for the situation where they're all the same cut and pasted oneliner and nothing else.