Repository navigation
Description
Biopython aspires to follow Python's docstring style guidelines in PEP257 https://www.python.org/dev/peps/pep-0257/ (and use reStructuredText for the docstrings).
We run the automatic tool pydocstyle on the code as part of the automated TravisCI tests (also used on pull requests). Right now this is configured to ignore many style violations. For example, the new release of pydocstyle v2.0.0 added some extra checks, most of which I just disabled in order that our TravisCI builds pass - see cc2ad72
This issue is about (gradually) cleaning up PEP257 compliance issues as flagged by the latest version of the pydocstyle tool, and removing entries from the ignore setting in our .pydocstyle configuration file.
Note that in some cases we as a community might agree to continue to ignore some of these items.
To install/upgrade this tool, use something like this (or just pip if you are still on Python 2):
$ pip3 install --upgrade pydocstyle
The following command simples a useful way to see a tally table for picking off the rarest cases to fix them first. The cut is to remove the variable part of the some messages containing text from the offending line.
$ pydocstyle Bio/ BioSQL/ Tests/ Scripts/ Doc/ --ignore "" | grep "^ D" | cut -d "(" -f 1 | sort | uniq -c | sort -n
11 D207: Docstring is under-indented
12 D104: Missing docstring in public package
18 D301: Use r""" if any backslashes in a docstring
24 D214: Section is over-indented
33 D405: Section name should be properly capitalized
35 D211: No blank lines allowed before class docstring
40 D100: Missing docstring in public module
43 D404: First word of the docstring should not be `This`
63 D412: No blank lines allowed between a section header and its content
85 D103: Missing docstring in public function
102 D212: Multi-line docstring summary should start at the first line
104 D403: First word of the first line should be properly capitalized
108 D209: Multi-line docstring closing quotes should be on a separate line
109 D210: No whitespaces allowed surrounding docstring text
114 D413: Missing blank line after last section
118 D101: Missing docstring in public class
123 D401: First line should be in imperative mood; try rephrasing
135 D208: Docstring is over-indented
140 D406: Section name should end with a newline
142 D407: Missing dashed underline after section
187 D205: 1 blank line required between summary line and description
254 D200: One-line docstring should fit on one line with quotes
275 D105: Missing docstring in magic method
283 D402: First line should not be the function's "signature"
354 D204: 1 blank line required after class docstring
569 D400: First line should end with a period
590 D203: 1 blank line required before class docstring
623 D401: First line should be in imperative mood
746 D102: Missing docstring in public method
2344 D213: Multi-line docstring summary should start at the second line
Once you've picked an entry to work on, run pydocstyle again selecting just that entry, e.g.:
$ pydocstyle Bio/ BioSQL/ Tests/ Scripts/ Doc/ --select D104
...
I've marked this issue as "Easy Fix" in the hope of encouraging new-comers to try fixing some of these issues. If you would like to work on one of these (e.g. fixing the D104 entries), please comment below to avoid duplicated effort, before starting work and submitting a pull request.
Note we will ask you to agree to dual licence your contributions under both the Biopython License Agreement AND the BSD 3-Clause License (see #898) and if you are you happy to be thanked by name in the NEWS.rst and CONTRIB.rst files (and under what name if this is not clear from your GitHub profile).
Update: You may find some of the modules have loads of issues, and instead it may make sense to work on all the docstring style or reStructuredText problems in that module at once. That's fine too - but again please comment on this issue to avoid duplication of effort.
Thanks!
Update: See #1203 for all the D1## entries about missing docstrings.
Activity
morrme commentedon Apr 19, 2017
I would like to help with this, but as I'm new to your codebase, I'd need a little mentoring to get started.
peterjc commentedon Apr 19, 2017
@morrme how about you try D211 then - it just means removing the blank lines which
pydocstyleis complaining about?You'll need to fork the Biopython repository, make a new branch, install and run
pydocstyle, fix the blank lines, commit the changes, push to your fork on GitHub, and then make a pull request. Does all of that make sense?morrme commentedon Apr 19, 2017
@peterjc yes, it does! i will get started with it and let you know if i run into any issues.
morrme commentedon Apr 19, 2017
@peterjc all done! what is the next rule on your wishlist?
peterjc commentedon Apr 19, 2017
@morrme Speedy! Thanks! Since you're not familiar with the codebase, I suggest you avoid the issues about missing docstrings. There are more blank line checks you could tackle if you like?
Or how about D301? It theory it should be easy if you're familiar with r"string" notation for raw strings to avoid the need to slash escape special characters, but I've not looked at why these are present here.
See also PyCQA/pydocstyle#249 - some of these fixes can surely be automated which will save lots of people effort in the long run.
morrme commentedon Apr 19, 2017
@peterjc sure, which ones are the blank line checks? D201-D205?
I can take a look at what is failing D301 as well.
A lot of these can definitely be fixed automatically. I hope that issue you made gets some traction!
Ignore pydocstyle D412 again
souravsingh commentedon Apr 21, 2017
@peterjc I think the coala PyDocStyleBear could be useful for automated checks.
peterjc commentedon Apr 21, 2017
@souravsingh That looks like a Coala wrapper for
pydocstyle, so wouldn't add anything directly, but using coala generally in our TravisCI/Tox style checks and/or git commit hook might be good. I suggest you comment on #883peterjc commentedon Apr 25, 2017
Cross reference PyCQA/pydocstyle#250 which would make it easier to merge changes to
.pydocstyleand comment why we still ignore some entries.pydocstyle D413 blank line after last section
62 remaining items
TravisCI/Tox: Enforce pydocstring D200, D204
Fix pydocstyle D208: Docstring is over-indented
Docstring style; fix pydocstyle D412
TravisCI/Tox style checks: Enforce D403
docstring style, D301: Use r""" if any backslashes in a docstring
Docstring work avoiding function's signature
flake8 and TravisCI/Tox: Enforce pydocstyle D402
peterjc commentedon Nov 23, 2017
Little change in the latest numbers, still ignoring the controversial D406 and D407:
peterjc commentedon Nov 23, 2017
I'm working on D205 right now...
peterjc commentedon Nov 23, 2017
I've started work on D400 now.
peterjc commentedon Nov 24, 2017
Pull request #1462 would fix and enforce D205 and D400 via our TravisCI/Tox style check, which would leave missing docstrings (#1203) and the following:
To be honest, while I would like to follow D401 imperative mood, it seems a very low priority.
I have started work on D301, cross reference discussion on #1173.
souravsingh commentedon Nov 24, 2017
I can work on the D401 if it is needed. If not, we can ignore the error.
peterjc commentedon Nov 24, 2017
Once #1462 (corrected) is merged I think we can close this issue :)
@saketkc If you want to try doing a few D401 cases, sure - give it a try. Please start on those modules you have contributed to and are most familiar with. Thank you.
peterjc commentedon Dec 11, 2017
Current numbers,
i.e. 416 cases of D401 which I have logged as #1473 as a low priority issue.
Closing this as most of the pydocstyle checks now pass. Horray - thank you everyone who contributed to this effort!