Repository navigation
PDBList local_dtd bug and other minor flake8-bugbear issues - #1728
Merged
Merged
Conversation
These two uses are Python 2 specific and thus appropriate.
This avoids a flake8-bugbear warning, B008 Do not perform calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time call. If this is intended, assign the function call to a module-level variable and use that variable as a default value. We already have a module-level variable with a shared instance of the generic protein alphabet - so use that.
Previously default would be the current directory at the
time of the import:
$ python -c "import os; print(os.getcwd()); from Bio.PDB.PDBList import PDBList; os.chdir('/tmp'); print(PDBList().local_pdb); os.chdir('/Users/peter/'); print(PDBList().local_pdb)"
/Users/peter/repositories/biopython
/Users/peter/repositories/biopython
/Users/peter/repositories/biopython
Now:
$ python -c "import os; print(os.getcwd()); from Bio.PDB.PDBList import PDBList; os.chdir('/tmp'); print(PDBList().local_pdb); os.chdir('/Users/peter/'); print(PDBList().local_pdb)"
/Users/peter/repositories/biopython
/private/tmp
/Users/peter
Spotted via flake8-bugbear,
Bio/PDB/PDBList.py:86:58: B008 Do not perform calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.
Codecov Report
@@ Coverage Diff @@
## master #1728 +/- ##
========================================
Coverage ? 85.6%
========================================
Files ? 327
Lines ? 50082
Branches ? 0
========================================
Hits ? 42872
Misses ? 7210
Partials ? 0
Continue to review full report at Codecov.
|
Member
Author
|
TravisCI use of |
peterjc
added a commit
to peterjc/biopython
that referenced
this pull request
Aug 24, 2018
Closes biopython#1515, thanks to work in pull request biopython#1748 and pull request biopython#1728.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses some minor issues noticed from running
flake8-bugbear,https://github.com/PyCQA/flake8-bugbear
I have ignored all the B007 warnings about loop variable names, and there are still 8 cases of B008 but they looked harmless.
Building on this, we could enable these checks on TravisCI (ignoring B007 and whitelisting the current B008 cases)?
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.rstfile and understand that AppVeyor andTravisCI will be used to confirm the Biopython unit tests and
flake8stylechecks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)