Repository navigation
Fix line numbers of code fences in docstrings - #75
Merged
Elias Freider (freider) merged 1 commit intoNov 4, 2026
Merged
Elias Freider (freider) merged 1 commit into
Elias Freider (freider) merged 1 commit into
Conversation
The docstring line offset assumed that the opening quotes are on their own line. Fences in docstrings with a summary on the opening line reported the line after the actual one, and fences in module docstrings reported the line before it. Docstrings with a string prefix (r""") were matched against their closing quotes, or not collected at all when the closing quotes share a line with other text.
Elias Freider (freider)
force-pushed
the
fix-docstring-line-offsets
branch
from
November 4, 2026 19:49
86c1399 to
30e3249
Compare
Collaborator
|
Makes sense, thanks for the fix! |
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.
Fixes the docstring line offset used for test IDs and tracebacks of code fences in Python docstrings.
get_docstring_start_lineassumed that the opening quotes are on their own line, whichinspect.getdocstrips as a leading blank line. The offset was wrong in these cases:"""Summary.): line numbers pointed one line after the actual line.inspect.getsourcelinesreturns 0 as the start line of a module, so line numbers pointed one line before the actual line.r"""): the search skipped the opening quotes and matched the closing quotes. When the closing quotes share a line with other text, the docstring was not collected at all.The offset now counts the leading blank lines that
inspect.getdocstrips, acceptsr/uprefixes, and treats a module start line as 1. Docstrings with the opening quotes on their own line keep the same line numbers.Issue: #74