Repository navigation
Split Numpydoc raises heads after their type - #171
Merged
Merged
Conversation
An item under Raises or Warns written as "ValueError : if bad." or "ValueError: if bad." had the whole line as its type. Split it as napoleon does: the type is ValueError, and "if bad." starts the description, which the indented lines below continue. Split only when what comes before the colon is one type, a dotted name maybe with a subscript, as Google's Raises reads it, so a line of prose with a colon in it stays whole. The type pattern moves to _text for both styles to share.
rr-
force-pushed
the
rework/33-numpydoc-raises
branch
from
November 6, 2026 17:59
e99be54 to
7c576bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In a Numpydoc
RaisesorWarnssection, an item written with its description on the head line made the whole line the type:gave a raises with
type_name='ValueError : if bad.'and the descriptionOr worse.. It now givestype_name='ValueError'and the descriptionif bad.\nOr worse., as sphinx napoleon reads it.ValueError: if bad.without the space before the colon splits the same way, andValueError :alone on its line takes its description from the indented lines below.The line splits only when what comes before the colon is one type: a dotted name, maybe with a subscript such as
pkg.Error[int]. That is the same type pattern Google'sRaises:already uses, so it moves to_textfor both styles to share. Prose with a colon, such asIf the value is bad: an error, and several types, such asKeyError, TypeError : if missing., stay whole as before. Compose already writes the type and the description on separate lines, so the split items read back unchanged.Parity against origin/main: 6 of 29,142 docstrings differ, 4 from the case files and 2 generated, none from the stdlib. The case ones are two pandas corpus docstrings (
TypeError : on inequality comparisonsandValueError : `match` does not ...) plus the newnumpydoc/raises_03andnumpydoc/warns_02cases. The generated ones are ay: thingitem and aYields:item that ended up under aRaisesheading, which now split into the typeywith the descriptionthing, and the typeYields. All of them differ inparse NUMPYDOCandparse AUTOand in their composes.Bench (
just bench): parse numpydoc 172.7 ms on main vs 171.8 ms (0.99x), and the other workloads 0.98x to 1.00x.