Skip to content

docstring_parser: normalise whitespace in types - #190

Merged
rr- merged 2 commits into
mainfrom
rework/55-types
Nov 7, 2026
Merged

rr- merged 2 commits into
mainfrom
rework/55-types

Conversation

@rr-

@rr- rr- commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Covers item 8 from the BEHAVIOR.md review for #136: "The remaining parts make up type_name, with whitespace normalized".

A type used to keep the spaces, tabs and newlines it was written with, so list of str, or a ReST :type: wrapped over two lines, gave a type_name with runs of spaces or a newline in it. In every style, each run of whitespace in a type is now one space. A part that quotes text, such as Literal["a b"], keeps its spaces. raw_type_name still holds the type as written.

Case diffs: two Twisted corpus files whose Epydoc @type wraps over two lines:

  • twisted.mail.tap.Options._getEndpoints
  • twisted.trial.reporter.TestResult.addUnexpectedSuccess

Parity against origin/main: 1037 of 29184 docstrings differ (case 2, stdlib 0, the rest generated). The generated ones are mixed inputs whose types swallowed a following line. Those types are now joined with a space instead of a newline.

A type kept the spaces, tabs and newlines it was written with, so a
type wrapped over two lines held a newline. Each run of whitespace in
a type is now one space, in every style, except in a part that quotes
text. raw_type_name still holds the type as written.
@rr- rr- self-assigned this Nov 7, 2026
@rr-
rr- merged commit 5f7dedd into main Nov 7, 2026
26 checks passed
@rr-
rr- deleted the rework/55-types branch November 7, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant