Skip to content

Comply with flake8-comprehensions upgrade - #2342

Merged
peterjc merged 4 commits into
biopython:masterfrom
chris-rands:flake8-comprehensions_upgrade
Nov 18, 2019
Merged

peterjc merged 4 commits into
biopython:masterfrom
chris-rands:flake8-comprehensions_upgrade

Conversation

@chris-rands

Copy link
Copy Markdown
Contributor

The upgrade of flake8-comprehensions (in particular see the changes for version 3.1.0) includes some new checks:
https://github.com/adamchainz/flake8-comprehensions/blob/master/HISTORY.rst

  • 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.)

@peterjc peterjc left a comment

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.

Assuming no test failures, this looks good - and using list(expr) is shorter than [x for x in expr] too. I'll have to get used to this as I probably over-use list comprehensions myself.

@peterjc

peterjc commented Nov 18, 2019

Copy link
Copy Markdown
Member

Hmm,

$ flake8
./Bio/Restriction/Restriction.py:1550:45: E231 missing whitespace after ':'
./Bio/Restriction/Restriction.py:1551:45: E231 missing whitespace after ':'
./Scripts/Restriction/ranacompiler.py:892:49: E231 missing whitespace after ':'

All three are in lambda expressions - not sure why they were not being reported before, but worth fixing now.

@codecov

codecov Bot commented Nov 18, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #2342 into master will increase coverage by 0.01%.
The diff coverage is 86.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2342      +/-   ##
==========================================
+ Coverage   84.94%   84.95%   +0.01%     
==========================================
  Files         323      323              
  Lines       52690    52690              
==========================================
+ Hits        44756    44765       +9     
+ Misses       7934     7925       -9
Impacted Files Coverage Δ
Bio/Phylo/_utils.py 65.16% <0%> (ø) ⬆️
Bio/SearchIO/BlastIO/blast_xml.py 93.9% <100%> (ø) ⬆️
Bio/SearchIO/_model/query.py 91.5% <100%> (ø) ⬆️
Bio/SeqIO/UniprotIO.py 92.3% <100%> (ø) ⬆️
Bio/AlignIO/MafIO.py 92.92% <100%> (ø) ⬆️
Bio/Nexus/Trees.py 80.28% <100%> (ø) ⬆️
Bio/SearchIO/_model/hit.py 93.33% <100%> (ø) ⬆️
Bio/codonalign/codonseq.py 87.53% <100%> (ø) ⬆️
Bio/SearchIO/InterproscanIO/interproscan_xml.py 95.49% <100%> (ø) ⬆️
Bio/SwissProt/__init__.py 92.66% <100%> (ø) ⬆️
... 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 af73d7e...6fbee20. Read the comment docs.

@chris-rands

Copy link
Copy Markdown
Contributor Author

Thanks Peter, i fixed those failures, I am confused about this one though, looking at the code, might be a false positive?

./Tests/test_GraphicsChromosome.py:312:29: C416 Unnecessary list comprehension - rewrite using list().

I also meant to say, this is the cause of the Travis failure in #2341

@peterjc

peterjc commented Nov 18, 2019

Copy link
Copy Markdown
Member

It looks legitimate to me, the tuple is expanded with an additional entry:

                features = [(start, end, strand, label, color)
                            for (start, end, strand, label) in features]

https://github.com/biopython/biopython/blob/biopython-175/Tests/test_GraphicsChromosome.py#L312

I don't see any flake8 complaint about this line via TravisCI though...

@chris-rands

chris-rands commented Nov 18, 2019 •

Copy link
Copy Markdown
Contributor Author

The build no longer fails with Travis because i added # noqa: C416 too the end of this line here

I'm now convinced this is an issue with the flake8-comprhensions plugin, I can reproduce this like:

$ cat tmp.py 
a = 0
x = [(1, 2, 3)]
x = [(b, c, d, a) for b, c, d in [(1, 2, 3)]]
$ flake8 --isolated --select C4 tmp.py 
tmp.py:3:6: C416 Unnecessary list comprehension - rewrite using list().

EDIT: i found the relevant bug report for this adamchainz/flake8-comprehensions#198

@peterjc

peterjc commented Nov 18, 2019

Copy link
Copy Markdown
Member

Good work.

@peterjc
peterjc merged commit 8151839 into biopython:master Nov 18, 2019
@chris-rands
chris-rands deleted the flake8-comprehensions_upgrade branch November 18, 2019 12:47
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