Skip to content

[WIP] Validate PEP-8 in docstrings #23194

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

Closed
wants to merge 4 commits into from

Conversation

dubielt1
Copy link

Potential blocks to closing

  • Adds dev dependency on pycodestyle, as I couldn't get the other libraries (such as pyflakes) to accept a string for PEP-8 validation, they all expect file names to read.
  • When printing the PEP-8 violations, the line numbers printed are with respect to the Example heading, e.g. the first example >>> ... is line 1. I tried reporting the actual file line number using doctest.Example.lineno, but it fails to report the correct line number when the docstring is defined outside of the function/method, and possibly modified as well? (e.g. pandas.io.excel.read_excel)

Tests added / passed

  • I haven't added tests yet, but plan to add some with PEP-8 violations to test_validate_docstrings.py

whatsnew

  • This is my first PR, not sure if I did this as expected

@pep8speaks
Copy link

Hello @dubielt1! Thanks for submitting the PR.

@datapythonista
Copy link
Member

Sorry @dubielt1 didn't see this PR until now.

The issue has already been fixed in #23399. Closing.

@FHaase, can you take a look to this PR, and see if there is anything that makes sense adding/changing to what you did?

@FHaase
Copy link
Contributor

FHaase commented Nov 9, 2018

Reading issue #23154 made me google for flake8 plugins, finding flake8_rst and flake8-docstrings.
After mentioning them in the issue discussion a couple days passed without any reaction so I looked into integrating flake8_rst. Didn't really want to steal @dubielt1's first PR.

From what I understand his idea is using DocTestParser to get the tests into pycodestyle.
We've done basically the same (examples_source_code() to get the tests, but flake8 which includes pycodestyle for generating the issues).

@datapythonista
Copy link
Member

Just wanted to make sure there was nothing in the PR that could be useful.

And it's unfortunate that we duplicate work, but it happens all the time in a project like pandas. Not sure if we can do much better than what we do on that.

Thanks for looking at this.

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.

Validate PEP-8 in docstring examples
4 participants