You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pydoc renders the parameter descriptions of some C functions with a different indentation #155236
bytes.rsplit is a clone of bytes.split, their docstrings contain the same description of sep, but pydoc renders them differently:
| split(self, /, sep=None, maxsplit=-1) | rsplit(self, /, sep=None, maxsplit=-1)
| Return a list of the sections ... | Return a list of the sections ...
| |
| sep | sep
| The delimiter according which ... | The delimiter according which ...
The docstring of split ends with the parameter descriptions, so the smallest indentation of all lines after the first one is 2, and inspect.cleandoc() removes it. The docstring of rsplit has one more paragraph which starts at the column 0, so nothing is removed.
As a result the same description is 2 characters wider in rsplit, and rewrapping it in split does not help.
69 of the documentation strings which contain an indented block are dedented, and 97 are not.
Since 3.13 the compiler removes the indentation of docstrings written in the source code (#81283), so the dedenting in cleandoc() now only affects documentation strings where the indentation is meaningful, like those generated by Argument Clinic.
I propose to add a dedent parameter in inspect.cleandoc() and inspect.getdoc(), and to not dedent in pydoc.
Activity
gh-155236: Add the dedent parameter in inspect.cleandoc() and inspect…
pythongh-155236: Add the dedent parameter in inspect.cleandoc() and i…