Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust docstring parsing #1323

Merged
merged 2 commits into from
Jan 29, 2025
Merged

More robust docstring parsing #1323

merged 2 commits into from
Jan 29, 2025

Conversation

mmatera
Copy link
Contributor

@mmatera mmatera commented Jan 29, 2025

In the current (master) documentation/doctest implementation, it is assumed that all the docstrings have a "margin" of spaces, comming from the class indentation. Then, the regular expression looking for doctests fails to find them if there is not at least a single space at the beginning of the line.
In the future, when we want to give support to Python 3.13, which removes the "left margin" of docstrings, the regular expression will fail finding some of the tests.
This PR changes the regular expression to allow doctests which do no start with a space.

Also, in future versions of Python, tab characters in docstrings will be converted into spaces, which will make to fail some tests. In this PR, tabs in doctests are replaced by sequences of 4 spaces, making the tests more robust under this kind of changes.

@rocky
Copy link
Member

rocky commented Jan 29, 2025

LGTM - thanks.

@rocky rocky merged commit 275a3b8 into master Jan 29, 2025
14 checks passed
@rocky rocky deleted the more_robust_docstring_parsing branch January 29, 2025 17:37
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.

2 participants