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

DOC: validate_docstrings.py should indicate the line numbers of PEP8 violations #24970

Open
dsaxton opened this issue Jan 27, 2019 · 4 comments

Comments

@dsaxton
Copy link
Member

dsaxton commented Jan 27, 2019

When checking docstrings the /scripts/validate_docstrings.py script tells which PEP8 violations have occurred in the examples, but not where. It would be helpful if the script also gave the line numbers of violations (as when running flake8 from the command line).

@WillAyd
Copy link
Member

WillAyd commented Jan 29, 2019

Makes sense to me - PRs are always welcome!

@datapythonista

@WillAyd WillAyd added this to the Contributions Welcome milestone Jan 29, 2019
@alexcwatt
Copy link
Contributor

This looks to be intentional; the validate_pep8 function includes this:

# We need this to avoid flake8 printing the names of the files to
# the standard output
application.formatter.write = lambda line, source: None
application.report()

@datapythonista
Copy link
Member

The problem on implementing this is that we don't know the lines. The approach to validate PEP-8 in the docstrings is to move all the code to a temporary file, and then run flake8 on that file.

We can implement an algorithm that maps the lines in the validated file, to the lines in the source code, but I don't think it's trivial.

If I'm not wrong, flake8 gives us the content of the failing lines, or we can get them from the temporary file with the line numbers reported by flake8. May be reporting the content of the failing lines would be good enough?

@bhavaniravi
Copy link
Contributor

Yes, even the lines that are failing will help to debug quickly. The current method I follow now is to comment out examples one after another to land upon the one that's causing the error and copy paste it to a python file to debug.

@mroeschke mroeschke removed this from the Contributions Welcome milestone Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants