Skip to content

converted Bio.Entrez to python3 - #2461

Merged
mdehoon merged 6 commits into
biopython:masterfrom
mdehoon:Entrez_python3
Jan 1, 2020
Merged

mdehoon merged 6 commits into
biopython:masterfrom
mdehoon:Entrez_python3

Conversation

@mdehoon

@mdehoon mdehoon commented Dec 29, 2019

Copy link
Copy Markdown
Contributor

This pull request is a first attempt to convert Bio.Entrez to python3. Please have a look before committing; this is tricky stuff. If we're happy with this, we can update the documentation.

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

@mdehoon
mdehoon requested a review from peterjc December 29, 2019 14:46
@codecov

codecov Bot commented Dec 29, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #2461 into master will decrease coverage by <.01%.
The diff coverage is 48.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2461      +/-   ##
==========================================
- Coverage   84.78%   84.78%   -0.01%     
==========================================
  Files         322      322              
  Lines       52388    52387       -1     
==========================================
- Hits        44419    44414       -5     
- Misses       7969     7973       +4
Impacted Files Coverage Δ
Bio/Entrez/__init__.py 45.33% <27.77%> (-2.56%) ⬇️
Bio/Entrez/Parser.py 82.56% <81.81%> (+0.37%) ⬆️

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 0f1f007...df98f79. Read the comment docs.

Comment thread Bio/Entrez/Parser.py
# Importing these functions with leading underscore as not intended for reuse
from Bio._py3k import urlopen as _urlopen
from Bio._py3k import urlparse as _urlparse
from urllib.request import urlopen, urlparse

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.

It is minor, but this way adds urlopen and urlparse to the namespace of Bio.Entrez.Parser whereas the following based on the old imports makes it clear they are for our internal use only:

from urllib.request import urlopen as _urlopen	
from urllib.request import urlparse as _urlparse

This would also mean less trivial changes in the rest of the file ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why add underscores fore these two imports and not to all the others?

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.

Let's discuss this on #2483

Comment thread Tests/test_Entrez_online.py Resolved
@peterjc

peterjc commented Dec 29, 2019

Copy link
Copy Markdown
Member

Dropping the previously documented support for parsing handles opened in text mode worries me. How about a fall back conversion with a new deprecation warning to make the transition to binary more easier on our users?

The handle.url change also worries me, but looks easy to address.

@mdehoon

mdehoon commented Dec 30, 2019 •

Copy link
Copy Markdown
Contributor Author

How about a fall back conversion with a new deprecation warning to make the transition to binary more easier on our users?

It is asking for trouble. By the time you have a text handle, you won't know the encoding that was used to open the file.

On top of that, the warning won't tell you what actually happened:

import warnings
  
def f():
    warnings.warn("some warning pops up")

def g():
    f()

g()

results in

script.py:4: UserWarning: some warning pops up
  warnings.warn("some warning pops up")

without a traceback, i.e. without telling the user where exactly the file was opened in text mode.

@mdehoon

mdehoon commented Dec 30, 2019

Copy link
Copy Markdown
Contributor Author

Not sure where the travis and appveyor errors are coming from. I haven't touched that file in the original PR or in the later commit.

@mdehoon

mdehoon commented Dec 30, 2019

Copy link
Copy Markdown
Contributor Author

Commit 66cce9d is causing the checks to fail

@peterjc

peterjc commented Dec 30, 2019

Copy link
Copy Markdown
Member

Breaking the master branch with the py3k unicode cleanup was my fault, sorry. We can rebase this to re-test...

@mdehoon

mdehoon commented Jan 1, 2020

Copy link
Copy Markdown
Contributor Author

Thanks

@mdehoon
mdehoon merged commit e813ef7 into biopython:master Jan 1, 2020
@mdehoon
mdehoon deleted the Entrez_python3 branch January 1, 2020 13:44
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