Skip to content

gh-155236: Add the dedent parameter in inspect.cleandoc() and inspect.getdoc() - #155237

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:pydoc-no-dedent
Open

gh-155236: Add the dedent parameter in inspect.cleandoc() and inspect.getdoc()#155237
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:pydoc-no-dedent

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 5, 2026

Copy link
Copy Markdown
Member

pydoc no longer dedents documentation strings, so the indentation of the parameter descriptions generated by Argument Clinic is preserved and does not depend on the rest of the docstring.

Only documentation strings written in C are affected -- 96 objects, like bin(), print() and the bytes methods. Docstrings written in the source code are dedented by the compiler since 3.13, so their rendering does not change.

Removing the dedenting from cleandoc() itself is not an option: it is still needed for documentation strings extracted from the source code (ast.get_docstring(), pygettext) and for arbitrary indented text.

…etdoc()

pydoc no longer dedents documentation strings, so the indentation of the
parameter descriptions generated by Argument Clinic is preserved and does
not depend on the rest of the docstring.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33924543 | 📁 Comparing 40c2e68 against main (1d90627)

  🔍 Preview build  

2 files changed
± library/inspect.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant