Skip to content

STYLE improve validate-docstrings ergonomics #52482

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

Merged

Conversation

MarcoGorelli
Copy link
Member

Before opening an issue for EX03 errors, I just wanted to improve the usability of validate_docstrings

Currently it's kind of hard to tell which lines need to change, especially if there's a long docstring.

Now, here's what it shows for python scripts/validate_docstrings.py pandas.Series.describe:

################################################################################
################################## Validation ##################################
################################################################################

3 Errors found for `pandas.Series.describe`:
        flake8 error: line 11, col 54: E231 missing whitespace after ','
        flake8 error: line 11, col 58: E231 missing whitespace after ','
        flake8 error: line 14, col 19: E124 closing bracket does not match visual indentation

From trying it out locally, this makes it much easier to tell what needs changing

@@ -1005,11 +1005,11 @@ class Window(BaseWindow):
Rolling sum with a window span of 2 seconds.

>>> df_time = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},
... index = [pd.Timestamp('20130101 09:00:00'),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't resist fixing up a docstring with these improved ergonomics

Comment on lines +8 to +9
# expected n blank lines
E3,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E3 shows things like "expected 2 blank lines, expected 0" which I think is a bit irrelevant for docstrings - we put the lines one after the other anyway, having empty >>> lines in docstrings wouldn't look good

@MarcoGorelli MarcoGorelli added Code Style Code style, linting, code_checks Docs labels Apr 6, 2023
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, very nice improvement, thanks @MarcoGorelli

@mroeschke mroeschke added this to the 2.1 milestone Apr 6, 2023
@mroeschke mroeschke merged commit e80dc87 into pandas-dev:main Apr 6, 2023
@mroeschke
Copy link
Member

Thanks @MarcoGorelli

topper-123 pushed a commit to topper-123/pandas that referenced this pull request Apr 6, 2023
improve `validate-docstrings` ergonomics

Co-authored-by: MarcoGorelli <>
@DeaMariaLeon
Copy link
Member

Arrived late to the party

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants