GeezerVison is showing github.com — Line overflow in pydoc output due to long docstrings · Issue #150285 · python/cpython
Line overflow in pydoc output due to long docstrings #150285DescriptionFollowing PEP 8 automatically leads to pydoc generating outpurt that fits in 80 columns, except some long signatures, inherited standard docstrings and URIs. Exceptions happen here and there, and I usually fix them whem working on the module. Things are more complicated with the C code. Old docstrings mostly fit in 80 columns, but Argument Clinic provokes writing longer lines. There is a check for docstring line width, but it is incorrect. It's now a chicken and egg problem. We cannot simply fix the limits in Argument Clinic, because this will produce a large amount of warnings and errors (especially in recently added modules), but until it was fixed, the new code will add too long docstrings.
There are only few modules which need large number of corrections and many modules which require only 1-2 fixes. Most modules do not need any changes. I am going to fix large modules in separate PRs, then fix many simple cases at once and fix the limits in Argument Clinic.
Linked PRs
Activityomkar-334 commented on May 23, 2026 hey @serhiy-storchaka is there any module i can help with, maybe the many small modules with 1-2 fixes? serhiy-storchaka commented on May 23, 2026 No, I already wrote them. I wait for merging the submitted PRs before uploading the rest. omkar-334 commented on May 23, 2026 ok, got it, thanks!....i am interested in contributing more so i had asked added 6 commits that reference this issue on Jun 11, 2026gh-150285: Fix too long docstrings in GenericAlias and __class_getite… gh-150285: Fix overflow in too long lines for class data in pydoc (GH… hugovk commented on Jun 14, 2026
@AlexWaygood Is there a Ruff rule that can prevent future overlong docstrings being introduced?
I don't know of one, unfortunately. A good way of answering that kind of question is usually to go to the Ruff playground, enable ALL in the configuration settings, and see if the code triggers any lints. We can see here that the very long first line triggers E501 (a general lint about lines being too long, which would also be triggered if it was a short sentence that was heavily indented), but doesn't trigger any specific lints about the first line of the docstring being a sentence that's too long. play.ruff.rs/c4ac905d-e485-4b24-a035-833ef07c4e84
I'd personally be happy to consider adding a rule like this (but I can't speak for the whole Ruff team -- definitely open an issue if it's something you're interested in!)
There's almost a rule for this, I've opened astral-sh/ruff#25995 :)
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|