Skip to content
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

TYP: Assorted_Typing_Fix in pandas.io #25939

Merged
merged 1 commit into from
Apr 11, 2019

Conversation

ryankarlos
Copy link
Contributor

@ryankarlos
Copy link
Contributor Author

There were some unused imports in packers module - i've left them in for now, not sure if the linter will complain as it was throwing warnings in flake8

@codecov
Copy link

codecov bot commented Mar 31, 2019

Codecov Report

Merging #25939 into master will decrease coverage by 49.89%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25939      +/-   ##
==========================================
- Coverage   91.81%   41.92%   -49.9%     
==========================================
  Files         175      175              
  Lines       52580    52597      +17     
==========================================
- Hits        48278    22049   -26229     
- Misses       4302    30548   +26246
Flag Coverage Δ
#multiple ?
#single 41.92% <100%> (-0.06%) ⬇️
Impacted Files Coverage Δ
pandas/io/feather_format.py 89.74% <100%> (+0.26%) ⬆️
pandas/io/json/table_schema.py 11.01% <100%> (-87.29%) ⬇️
pandas/io/packers.py 16.71% <100%> (-71.37%) ⬇️
pandas/io/parquet.py 20.19% <100%> (-64.28%) ⬇️
pandas/io/json/normalize.py 9.09% <100%> (-87.85%) ⬇️
pandas/io/json/json.py 63.51% <100%> (-29.72%) ⬇️
pandas/io/html.py 19.7% <100%> (-72.95%) ⬇️
pandas/io/formats/latex.py 0% <0%> (-100%) ⬇️
pandas/io/sas/sas_constants.py 0% <0%> (-100%) ⬇️
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
... and 137 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 de3a85c...f24159e. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 31, 2019

Codecov Report

Merging #25939 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25939      +/-   ##
==========================================
- Coverage    91.9%   91.89%   -0.01%     
==========================================
  Files         175      175              
  Lines       52485    52485              
==========================================
- Hits        48235    48230       -5     
- Misses       4250     4255       +5
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 40.75% <ø> (-0.13%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/frame.py 96.79% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.62% <0%> (-0.11%) ⬇️

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 6d9b702...e08ab93. Read the comment docs.

@ryankarlos
Copy link
Contributor Author

@WillAyd Was getting an azure pipeline error when removing ununsed import DataFrame, Panel, Float64Index, Int64Index but removing them makes everything fail now

@WillAyd
Copy link
Member

WillAyd commented Mar 31, 2019

@ryankarlos that does seem strange - have you been able to debug that issue locally?

@ryankarlos
Copy link
Contributor Author

ryankarlos commented Mar 31, 2019

@WillAyd Something strange - when i debug locally I can reproduce the same error - problem seems to be mainly with packers - when i include the unused imports DataFrame, Panel in packers.py and run the test on test_packers.py it passes but when I exclude either of them or both from the packers module it fails. I am not too experienced with the import machinery but this seems a bit strange. There are a few more unused imports like Float64Index, Int64Index which do not seem to be causing the tests to fail when removing them. Is there a way to make the linter ignore unused imports (in which case I could just include them all) or is it critical that these are picked up ?

TEST 1 (after including both DataFrame and Panel imports )

====================================================================
test session starts ====================================================================
platform darwin -- Python 3.7.2, pytest-4.1.1, py-1.7.0, pluggy-0.8.1`
hypothesis profile 'ci' -> deadline=500, timeout=unlimited, suppress_health_check=[HealthCheck.too_slow], database=DirectoryBasedExampleDatabase('/Users/ryannazareth/Documents/Python_sprints/pandas-ryankarlos/.hypothesis/examples')
rootdir: /Users/ryannazareth/Documents/Python_sprints/pandas-ryankarlos, inifile: setup.cfg
plugins: xdist-1.26.0, forked-0.2, cov-2.6.1, hypothesis-4.5.0
collected 83 items

pandas/tests/io/test_packers.py .........................................s.s.ss.s............s.s..s.s.sss.......... [100%]

=========================================================== 71 passed, 12 skipped in 2.38 seconds ===========================================================

TEST 2 (after excluding Panel import)

            return make_block(values=values,
                              klass=getattr(internals, b['klass']),
                              placement=placement,
                              dtype=b['dtype'])

        blocks = [create_block(b) for b in obj['blocks']]
      return globals()[obj['klass']](BlockManager(blocks, axes))

E KeyError: 'Panel'

pandas/io/packers.py:667: KeyError
===================================================== 22 failed, 49 passed, 12 skipped in 6.31 seconds ======================================================

@jreback
Copy link
Contributor

jreback commented Mar 31, 2019

msgpack needs the imports to correctly dessrialize things

you cannot remove them

@WillAyd WillAyd added the Typing type annotations, mypy/pyright type checking label Apr 1, 2019
@ryankarlos
Copy link
Contributor Author

ryankarlos commented Apr 1, 2019

Thanks, ok just pushed the imports but what do i do with the linter complaining about unused imports ?

@jbrockmendel
Copy link
Member

but what do i do with the linter complaining about unused imports ?

# noqa:F401 I think

Can you merge master

@ryankarlos
Copy link
Contributor Author

@jbrockmendel thanks

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.

lgtm @jreback

@WillAyd WillAyd added this to the 0.25.0 milestone Apr 10, 2019
@@ -12,8 +12,9 @@

from pandas.core.dtypes.common import is_period_dtype

from pandas import DataFrame, MultiIndex, Series, compat, isna, to_datetime
from pandas.core.reshape.concat import concat
from pandas import MultiIndex, compat, concat, isna, to_datetime
Copy link
Contributor

Choose a reason for hiding this comment

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

DataFrame/Series should be from pandas (same for all places)

@WillAyd
Copy link
Member

WillAyd commented Apr 10, 2019

@ryankarlos do we even need this PR any more? I think fixed by the implicit import PR you did earlier

Copy link
Contributor Author

@ryankarlos ryankarlos left a comment

Choose a reason for hiding this comment

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

@WillAyd I still think it would be useful to have this PR as Ive just noticed a few places which could still be importing from top level even after reverting all changes ... see comments below.
I fixed these now in latest commit

from pandas import compat
from pandas.core.frame import DataFrame
from pandas.core.index import MultiIndex
from pandas.core.missing import isna
from pandas.core.reshape.concat import concat
Copy link
Contributor Author

@ryankarlos ryankarlos Apr 10, 2019

Choose a reason for hiding this comment

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

like here

@@ -12,9 +12,9 @@
is_datetime64tz_dtype, is_integer_dtype, is_numeric_dtype, is_period_dtype,
is_string_dtype, is_timedelta64_dtype)

from pandas import DataFrame
from pandas.api.types import CategoricalDtype
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@WillAyd and here

@WillAyd
Copy link
Member

WillAyd commented Apr 10, 2019

I would rather just boil this PR down to removing the blacklist items if no further changes to imports are required

@ryankarlos ryankarlos force-pushed the Assorted_Typing_Fix_pandas.io branch from e0097f9 to 90b4383 Compare April 10, 2019 17:41
@ryankarlos
Copy link
Contributor Author

So OK for me to completely reset changes in this PR as well and only keep mypy.ini changes ?

@WillAyd
Copy link
Member

WillAyd commented Apr 10, 2019

Yes - the rest of the elements are arguably orthogonal at this point. Can be changed in separate more comprehensive PRs if we desire

@ryankarlos ryankarlos force-pushed the Assorted_Typing_Fix_pandas.io branch from 90b4383 to e08ab93 Compare April 10, 2019 23:45
@ryankarlos
Copy link
Contributor Author

Ok thanks - just pushed only mypy changes and reset everything else here and in #25936. Just waiting for tests to pass.

@WillAyd WillAyd merged commit e02ec8f into pandas-dev:master Apr 11, 2019
@WillAyd
Copy link
Member

WillAyd commented Apr 11, 2019

Thanks @ryankarlos !

@ryankarlos ryankarlos deleted the Assorted_Typing_Fix_pandas.io branch April 11, 2019 21:08
@ryankarlos ryankarlos changed the title Assorted_Typing_Fix in pandas.io TYP:Assorted_Typing_Fix in pandas.io Jan 6, 2020
@ryankarlos ryankarlos changed the title TYP:Assorted_Typing_Fix in pandas.io TYP: Assorted_Typing_Fix in pandas.io Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assorted Typing Fixups in pandas.io
4 participants