loader: use inspect
to make callable docs consistent
#2071
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Our own
trim_docstring
function is OK, but definitely not perfect. What it returns can be inconsistently indented depending on whether the docstring passed in is single- or multi-line, or whether a multi-line docstring starts on line 0 or line 1 (next to or below the"""
). It's nice to have consistent indentation.I don't have any strong feelings about where to implement this. Maybe it would make more sense to apply
inspect.cleandoc()
inside the logic oftrim_docstring
instead of usinginspect.getdoc()
on the callable. Either way, our help infrastructure will be easier to improve if we eliminate anything like this that can cause inconsistent output.Checklist
make qa
(runsmake quality
andmake test
)Not tested yet (see notes)CI did its jobNotes
I know this has a merge conflict; it's an old branch I found while cleaning up now that most of 7.1.0's stuff is merged. I'll take care of that (or overwrite the branch with a different approach) when the time comes.