Skip to content

fix: do not split summary on a period inside an inline literal - #363

Merged
weibullguy merged 2 commits into
PyCQA:masterfrom
Sanjays2402:fix/inline-literal-sentence-split
Aug 3, 2026
Merged

fix: do not split summary on a period inside an inline literal#363
weibullguy merged 2 commits into
PyCQA:masterfrom
Sanjays2402:fix/inline-literal-sentence-split

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #353.

do_split_summary ended the summary at any token ending in ., so a docstring containing an inline literal like ``.. deprecated::`` was split in the middle of the literal, producing invalid reST. It now skips the sentence break while inside an unclosed inline literal (odd number of `` markers), mirroring the existing ABBREVIATIONS false-positive guard.

Regression test fails without the source change and passes with it; the rest of the suite is unchanged (same 10 pre-existing test_do_format_code failures before and after).

Sanjays2402 and others added 2 commits July 25, 2026 16:43
do_split_summary treated any token ending in '.' as the end of the
summary sentence, so a docstring containing an inline literal such as
``.. deprecated::`` was split in the middle of the literal, producing
invalid reST.

Track whether the text seen so far is inside an unclosed inline literal
(an odd number of double-backtick markers) and skip the sentence break
in that case, mirroring the existing ABBREVIATIONS false-positive guard.

Adds a regression test covering both a literal-only summary and a
literal followed by a genuine second sentence.
@weibullguy
weibullguy merged commit 21f97a7 into PyCQA:master Aug 3, 2026
6 of 7 checks passed
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.

False read . in code-block as sentence ending

2 participants