Skip to content

CLN: PY3 String/BytesIO #25954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 3, 2019
Merged

CLN: PY3 String/BytesIO #25954

merged 11 commits into from
Apr 3, 2019

Conversation

mroeschke
Copy link
Member

Imports StringIO and BytesIO from io. Removes cStringIO

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Minor arguably unrelated request but I think makes sense to address here. Otherwise lgtm

@mroeschke mroeschke added this to the 0.25.0 milestone Apr 2, 2019
@codecov
Copy link

codecov bot commented Apr 2, 2019

Codecov Report

Merging #25954 into master will decrease coverage by <.01%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25954      +/-   ##
==========================================
- Coverage   91.82%   91.81%   -0.01%     
==========================================
  Files         175      175              
  Lines       52581    52584       +3     
==========================================
+ Hits        48280    48282       +2     
- Misses       4301     4302       +1
Flag Coverage Δ
#multiple 90.37% <91.3%> (ø) ⬆️
#single 41.9% <73.91%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/compat/__init__.py 71.71% <ø> (+1%) ⬆️
pandas/io/formats/format.py 97.89% <100%> (ø) ⬆️
pandas/io/json/json.py 93.24% <100%> (+0.01%) ⬆️
pandas/io/common.py 91.87% <100%> (ø) ⬆️
pandas/io/formats/csvs.py 98.2% <100%> (ø) ⬆️
pandas/core/series.py 93.67% <100%> (ø) ⬆️
pandas/core/computation/expr.py 88.55% <100%> (+0.02%) ⬆️
pandas/core/frame.py 96.79% <100%> (-0.12%) ⬇️
pandas/core/computation/scope.py 93.13% <100%> (+0.06%) ⬆️
pandas/io/clipboards.py 100% <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 00c119c...bead183. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 2, 2019

Codecov Report

Merging #25954 into master will decrease coverage by <.01%.
The diff coverage is 92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25954      +/-   ##
==========================================
- Coverage   91.84%   91.84%   -0.01%     
==========================================
  Files         175      175              
  Lines       52553    52552       -1     
==========================================
- Hits        48269    48267       -2     
- Misses       4284     4285       +1
Flag Coverage Δ
#multiple 90.4% <92%> (ø) ⬆️
#single 41.9% <76%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/compat/__init__.py 74.43% <ø> (+1.24%) ⬆️
pandas/io/formats/format.py 97.89% <100%> (ø) ⬆️
pandas/io/json/json.py 93.24% <100%> (+0.01%) ⬆️
pandas/io/common.py 91.87% <100%> (ø) ⬆️
pandas/io/formats/csvs.py 98.2% <100%> (ø) ⬆️
pandas/core/series.py 93.67% <100%> (ø) ⬆️
pandas/core/computation/expr.py 88.55% <100%> (+0.02%) ⬆️
pandas/core/frame.py 96.79% <100%> (-0.12%) ⬇️
pandas/core/computation/scope.py 93.13% <100%> (+0.06%) ⬆️
pandas/io/clipboards.py 100% <100%> (ø) ⬆️
... and 8 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 f90f4aa...250812d. Read the comment docs.

@mroeschke
Copy link
Member Author

@WillAyd mind helping me interpret these typing errors (not too familiar with mypy)?

pandas/io/common.py:414: error: Definition of "__enter__" in base class "ZipFile" is incompatible with definition in base class "BytesIO"
pandas/io/common.py:414: error: Definition of "__enter__" in base class "ZipFile" is incompatible with definition in base class "BinaryIO"
pandas/io/common.py:414: error: Definition of "__enter__" in base class "ZipFile" is incompatible with definition in base class "IO"
pandas/io/common.py:414: error: Definition of "__exit__" in base class "ZipFile" is incompatible with definition in base class "BytesIO"
pandas/io/common.py:414: error: Definition of "read" in base class "ZipFile" is incompatible with definition in base class "BytesIO"
pandas/io/common.py:414: error: Definition of "read" in base class "ZipFile" is incompatible with definition in base class "IO"
pandas/io/common.py:414: error: Definition of "write" in base class "ZipFile" is incompatible with definition in base class "BytesIO"
pandas/io/common.py:414: error: Definition of "write" in base class "ZipFile" is incompatible with definition in base class "BinaryIO"
pandas/io/common.py:414: error: Definition of "write" in base class "ZipFile" is incompatible with definition in base class "IO"

AFAICT, it has to do with this class defintion

class BytesZipFile(zipfile.ZipFile, BytesIO):

@WillAyd
Copy link
Member

WillAyd commented Apr 2, 2019 via email

@WillAyd
Copy link
Member

WillAyd commented Apr 3, 2019

So the error messages here are rather explicit; the problem is that with multiple inheritance the two classes that object derives from has conflicting signatures. Here's a related issue on the MyPy tracker:

python/mypy#2125

This code is pretty tricky though - do you see a test case that actually hits this? Actually wondering if multiple inheritance is even required or if it can subclass ZipFile directly, given it's constructor matches that and the call to writestr can accept bytes or str anyway.

If not then ignoring the types might be the only way to go about this

@mroeschke
Copy link
Member Author

Thanks for the tips @WillAyd. Since this PR isn't concerned with typing just ignoring the typing check for the BytesZipFile class.

@jreback jreback merged commit 9caf58f into pandas-dev:master Apr 3, 2019
@mroeschke mroeschke deleted the py3_io branch April 3, 2019 20:26
@jreback
Copy link
Contributor

jreback commented Apr 3, 2019

thanks @mroeschke

@WillAyd its ok to ignore these for now; can circle back later (maybe even add a check to detect types we are ignoring).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants