Skip to content

docstring D205, D400 (one line summary) & D301 (slashes) - #1462

Merged
peterjc merged 18 commits into
biopython:masterfrom
peterjc:docstring_D205
Nov 28, 2017
Merged

peterjc merged 18 commits into
biopython:masterfrom
peterjc:docstring_D205

Conversation

@peterjc

@peterjc peterjc commented Nov 23, 2017 •

Copy link
Copy Markdown
Member

This pull request addresses issue #1170

@etal @JoaoRodrigues do the PDB changes make sense?

(Further commits to follow for remaining cases in Bio.Phylo and Bio.SearchIO)

Update: Expanded from D205 to also cover D400 and D301 as well.

@codecov

codecov Bot commented Nov 23, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #1462 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1462   +/-   ##
======================================
  Coverage    84.8%   84.8%           
======================================
  Files         321     321           
  Lines       49312   49312           
======================================
  Hits        41817   41817           
  Misses       7495    7495
Impacted Files Coverage Δ
Bio/SeqIO/SeqXmlIO.py 86.46% <ø> (ø) ⬆️
Bio/Sequencing/Applications/_bwa.py 100% <ø> (ø) ⬆️
Bio/Seq.py 98.47% <ø> (ø) ⬆️
Bio/Phylo/Consensus.py 83.04% <ø> (ø) ⬆️
Bio/SeqIO/PdbIO.py 95% <ø> (ø) ⬆️
Bio/SCOP/Raf.py 87.09% <ø> (ø) ⬆️
Bio/SearchIO/_utils.py 86.2% <ø> (ø) ⬆️
Bio/PDB/Superimposer.py 93.54% <ø> (ø) ⬆️
Bio/SeqIO/PhdIO.py 98.03% <ø> (ø) ⬆️
Bio/Emboss/Applications.py 66.41% <ø> (ø) ⬆️
... and 48 more

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 e6a8726...6490ac4. Read the comment docs.

@peterjc

peterjc commented Nov 23, 2017

Copy link
Copy Markdown
Member Author

@bow Are the Bio.SearchIO docstring changes OK?

@etal, @brandoninvergo @lijax are the Bio.Phylo changes OK?

Comment welcomed on the other modules docstrings changed too, thanks!

As far as I can tell, these backslashes are all used
literally in the docstrings, and thus the docstrings
should be in raw mode (fixes pydocstyle D301).
Passing a literal tab character in a command line string
is problematic (and would require quoting which our wrapper
does not attempt to do). Instead, BWA itself understands the
backslash-t notation to insert a tab in the read group string.

This means when constructing the argument in Python, we need
to escape the backslash - or use a raw string.

This also fixes the doctest output which was showing white
space in the expected output of the command line as a string.

Bonus: This is the last D301 issue from pydocstyle/flake8
Cross reference issue 1170.
@peterjc peterjc changed the title Fixing docstring D205 style (one line summary lines) docstring D205, D400 (one line summary) & D301 (slashes) Nov 24, 2017
@peterjc

peterjc commented Nov 24, 2017

Copy link
Copy Markdown
Member Author

@saketkc could you check the changes to the bwa doctests please (dealing with unescaped slashes), thanks?

input_bam=in_bam)
>>> print(samtools_merge_cmd)
>>> merge_cmd = SamtoolsMergeCommandline(out_bam=out_bam,
... input_bam=in_bam)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation seems off.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does look wrong on GitHub, I agree. Maybe emacs stuck a tab in there? I must check that...

Comment thread Bio/PDB/PDBList.py Outdated
@staticmethod
def _print_default_format_warning(file_format):
"""Temporary warning (similar to a deprecation warning) that files are being downloaded in mmCIF"""
"""Print a warning to stdout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this end with '(PRIVATE)' like in Bio/Nexus/Nexus.py so as to keep this consistent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, especially since it is so short. Good spot.

Comment thread Bio/Phylo/Consensus.py Outdated

def _part(clades):
"""Recursive function of adam consensus algorithm"""
"""Recursive function of Adam Consensus algorithm."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRIVATE?

Comment thread Bio/Phylo/Consensus.py Outdated

def _sub_clade(clade, term_names):
"""Extract a compatible subclade that only contains the given terminal names"""
"""Extract a compatible subclade that only contains the given terminal names."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRIVATE?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ideally, but it is already a very long line.

Comment thread Bio/SearchIO/BlastIO/blast_tab.py Outdated
"""Returns a list of column short names from the 'Fields'
comment line.
"""
"""Return column short names line from 'Fields' comment line."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRIVATE?

# sequence properties #
def _set_seq(self, seq, seq_type):
"""Checks the given sequence for attribute setting
"""Checks the given sequence for attribute setting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRIVATE?

Comment thread Bio/motifs/jaspar/db.py

def _fetch_counts_matrix(self, int_id):
"""Fetch the counts matrix from the JASPAR DB by the internal ID
"""Fetch the counts matrix from the JASPAR DB by the internal ID.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRIVATE?

Comment thread Bio/SearchIO/ExonerateIO/_base.py Outdated
def _adjust_aa_seq(fraglist):
"""Transforms three-letter amino acid codes into one-letters in the
given HSPFragments.
"""Transform fragment's 3-letter amino acid codes to one-letter (PRIVATE).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably 'Transform 3-letter AA codes of input fragments to one-letter codes (PRIVATE).' is a better description.

@bow

bow commented Nov 25, 2017

Copy link
Copy Markdown
Member

@peterjc , aside from the comments @saketkc has made, I've added just one suggestion. The rest seems fine.

Comment thread Bio/Phylo/NewickIO.py Outdated
"""Final processing of a parsed clade. Removes the node's parent and
returns it.
"""
"""Final processing of parsed clade. Removes node's parent and return it."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Removes" -> "Remove"

@etal

etal commented Nov 25, 2017

Copy link
Copy Markdown
Contributor

The Phylo and PDB changes look fine to me.

Saket Choudhary noted many of the docstrings for private
methods and functions lacked our convention of (PRIVATE)
at the end of the one line summary.

TODO: Review the full code base for this.

I also made many of these docstrings use imperative mood
(pydocstyle D401 style check).
There are hundreds more, this grep command will find all
those after a single line def statement:

grep --include '*.py' -rn -A 1 "def _[a-z]" Bio BioSQL | grep '"""' | grep -v "(PRIVATE)"
@peterjc

peterjc commented Nov 28, 2017

Copy link
Copy Markdown
Member Author

I've logged #1466 for missing (PRIVATE) in our private function/method's docstrings.

@peterjc
peterjc merged commit a2c0d64 into biopython:master Nov 28, 2017
@peterjc

peterjc commented Nov 28, 2017

Copy link
Copy Markdown
Member Author

Thank you all - those extra eyes caught a few things I'd missed.

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.

4 participants