Skip to content

Apply Black to Doc/examples/ & start checking in CI - #2373

Merged
peterjc merged 5 commits into
biopython:masterfrom
peterjc:black_examples
Dec 6, 2019
Merged

peterjc merged 5 commits into
biopython:masterfrom
peterjc:black_examples

Conversation

@peterjc

@peterjc peterjc commented Dec 3, 2019

Copy link
Copy Markdown
Member

This pull request addresses issue #2008 in part.

  • 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, have run flake8 locally, and
    understand that AppVeyor and TravisCI will be used to confirm the Biopython unit
    tests and 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.)

@codecov

codecov Bot commented Dec 3, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #2373 into master will increase coverage by 0.07%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2373      +/-   ##
=========================================
+ Coverage   84.93%     85%   +0.07%     
=========================================
  Files         323     323              
  Lines       52884   53152     +268     
=========================================
+ Hits        44918   45184     +266     
- Misses       7966    7968       +2
Impacted Files Coverage Δ
BioSQL/Loader.py 78.65% <0%> (ø) ⬆️
BioSQL/BioSeq.py 93.41% <100%> (ø) ⬆️
Bio/_py3k/__init__.py 72.41% <0%> (-4.6%) ⬇️
Bio/Restriction/Restriction.py 84.51% <0%> (-0.32%) ⬇️
Bio/PopGen/GenePop/Controller.py 64.47% <0%> (-0.2%) ⬇️
Bio/Graphics/__init__.py 83.33% <0%> (ø) ⬆️
Bio/Graphics/KGML_vis.py 68.89% <0%> (ø) ⬆️
Bio/Graphics/DisplayRepresentation.py 93.84% <0%> (ø) ⬆️
Bio/Graphics/BasicChromosome.py 93.71% <0%> (ø) ⬆️
Bio/Graphics/Distribution.py 93.63% <0%> (ø) ⬆️
... and 5 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 f7e609f...827718c. Read the comment docs.

@peterjc

peterjc commented Dec 3, 2019

Copy link
Copy Markdown
Member Author

I had a silly typo in the tox configuration, but also some of the other files need black run on them...

@peterjc

peterjc commented Dec 3, 2019

Copy link
Copy Markdown
Member Author

Looks like I didn't have black version 19.10b0 installed locally, but the previous release. This introduces a couple of further changes - something to beware of in future.

Comment thread BioSQL/BioSeq.py
return None
assert len(seqs) == 1
given_length, = seqs[0]
(given_length,) = seqs[0]

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.

Why using a one-element tuple here? (If I understand this correctly).
Can't we use just return int(seqs[0])?

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.

I don't recall why the code was written that way in the first place, but it was me: 877a5f2

There must be something unintuitive about the DB results object, the obvious fix fails:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'

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.

There are more of these in Bio/File.py, see e.g.

https://github.com/biopython/biopython/blob/biopython-175/Bio/File.py#L585

It seems to be an (anti) pattern with DB access.

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.

OK, now I got it, the contents of seqs[0] is a one-element tuple.

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.

Actually, I was irritated in the first place that tuple unpacking now also requires parenthesis. I don't like it, but OK.

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.

Ah - I was more bothered on why there was tuple unpacking (I wrote the code years ago, but this was non-obvious). I'm on the fence about the recent black style change - adding the brackets makes it difficult to overlook the tuple unpacking - previously that trailing comma was easy to miss.

+ [grey, blue]
+ [lightblue] * 2
+ [grey] * 8
)

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.

Personally, I would use the parentheses to get rid of the line continuation backshlashes, but would turn black off here. On my 17'' laptop, these three lists fill the whole screen.

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.

I agree on parentheses over slash line continuation, but actually don't mind black taking a screen's worth of vertical space for defining these lists - they are a key part of the graphical example.

Comment thread Scripts/debug/debug_blast_parser.py Outdated
sys.stderr.write(USAGE)
sys.exit(-1)
TESTFILE, = args
(TESTFILE,) = args

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.

TESTFILE = args[0]?

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.

This dates back to the original check in, bbe8f5c - but I agree with the suggestion.

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.

However, the script no longer works - Bio.ParserSupport was removed in Release 1.72, while Bio.Blast.NCBIStandalone was moved away to Bio.SearchIO._legacy as an interim measure. We can just remove the entire script.

The modules this used were removed in Biopython 1.72,
and we should have removed this script then too. There
is no need to update/replace this example, since we
deprecated the plain text BLAST parsing.
@peterjc
peterjc merged commit d51950c into biopython:master Dec 6, 2019
@peterjc

peterjc commented Dec 6, 2019

Copy link
Copy Markdown
Member Author

Thanks Markus.

@peterjc
peterjc deleted the black_examples branch December 6, 2019 13:17
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.

2 participants