Skip to content

Fix and enforce flake8 D400 (trailing dots on docstrings) in Tests/ - #2020

Merged
peterjc merged 6 commits into
biopython:masterfrom
peterjc:d400
Apr 22, 2019
Merged

peterjc merged 6 commits into
biopython:masterfrom
peterjc:d400

Conversation

@peterjc

@peterjc peterjc commented Apr 19, 2019

Copy link
Copy Markdown
Member

Like #2016 and #2017, this pull request is somewhat related to issue #883 / #2014 and the goal of having universal flake8 settings for the entire project.

  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file and understand that AppVeyor and
    TravisCI will be used to confirm the Biopython unit tests and flake8 style
    checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

peterjc added 3 commits April 19, 2019 15:42
Done with the following script, reverting false positives in
several files triggered by missing docstrings which the script
does not consider:

import sys

def fix(lines):
    answer = []
    post_def = False
    for line in lines:
        if line.lstrip().startswith(("def ", "class ")):
            # print(line.rstrip())
            post_def = True
        if post_def and line.lstrip().startswith('"""'):
            post_def = False
            # Looks like line one of a docstring
            if line.rstrip().endswith('"""'):
                # a one-liner
                if line.rstrip().endswith('."""'):
                    # good
                    pass
                elif line.rstrip().endswith(('?"""', '!"""')):
                    # ugly
                    pass
                else:
                    print(line.rstrip())
                    line = line.rstrip()[:-3] + '."""\n'
            else:
                # multi-liner
                if line.rstrip().endswith('.'):
                    # good
                    pass
                elif line.rstrip().endswith(('?', '!')):
                    # ugly
                    pass
                else:
                    print(line.rstrip())
                    line = line.rstrip() + ".\n"
        answer.append(line)
    return answer

for f in sys.argv[1:]:
    print(f)
    with open(f) as handle:
        old = list(handle)
    new = fix(old)
    with open(f, "w") as handle:
        for line in new:
            handle.write(line)
print("Done")
These last cases were done by hand.
@codecov

codecov Bot commented Apr 19, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #2020 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2020      +/-   ##
==========================================
- Coverage    85.1%   85.08%   -0.02%     
==========================================
  Files         314      314              
  Lines       50302    50302              
==========================================
- Hits        42809    42801       -8     
- Misses       7493     7501       +8
Impacted Files Coverage Δ
Bio/_py3k/__init__.py 72.61% <0%> (-3.58%) ⬇️
Bio/Application/__init__.py 86.56% <0%> (-1.19%) ⬇️
Bio/File.py 87.01% <0%> (-0.26%) ⬇️
Bio/Entrez/Parser.py 81.57% <0%> (-0.18%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89a315f...5131e23. Read the comment docs.

@peterjc

peterjc commented Apr 19, 2019

Copy link
Copy Markdown
Member Author

Missed two files... updating branch...

@peterjc
peterjc merged commit db6c7f2 into biopython:master Apr 22, 2019
@peterjc

peterjc commented Apr 22, 2019

Copy link
Copy Markdown
Member Author

Thanks everyone for looking at this.

@peterjc
peterjc deleted the d400 branch April 22, 2019 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants