TYP: Assorted_Typing_Fix in pandas.io
State: closed

- [x] closes #25933
- [ ] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Typing
description: type annotations, mypy/pyright type checking

Comments:
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](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=h1) Report
> Merging [#25939](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/de3a85c8404505ace0c0febc26b1fbe824f48034?src=pr&el=desc) will **decrease** coverage by `49.89%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25939/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=tree)

```diff
@@            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%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/feather\_format.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2ZlYXRoZXJfZm9ybWF0LnB5) | `89.74% <100%> (+0.26%)` | :arrow_up: |
| [pandas/io/json/table\_schema.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vdGFibGVfc2NoZW1hLnB5) | `11.01% <100%> (-87.29%)` | :arrow_down: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `16.71% <100%> (-71.37%)` | :arrow_down: |
| [pandas/io/parquet.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhcnF1ZXQucHk=) | `20.19% <100%> (-64.28%)` | :arrow_down: |
| [pandas/io/json/normalize.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vbm9ybWFsaXplLnB5) | `9.09% <100%> (-87.85%)` | :arrow_down: |
| [pandas/io/json/json.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vanNvbi5weQ==) | `63.51% <100%> (-29.72%)` | :arrow_down: |
| [pandas/io/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2h0bWwucHk=) | `19.7% <100%> (-72.95%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| ... and [137 more](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=footer). Last update [de3a85c...f24159e](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=h1) Report
> Merging [#25939](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/6d9b702a661891724e6c10dd96eb149404205c67?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25939/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=tree)

```diff
@@            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% <ø> (ø)` | :arrow_up: |
| #single | `40.75% <ø> (-0.13%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `75% <0%> (-12.5%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.79% <0%> (-0.12%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25939/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `90.62% <0%> (-0.11%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=footer). Last update [6d9b702...e08ab93](https://codecov.io/gh/pandas-dev/pandas/pull/25939?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@WillAyd Was getting an azure pipeline error when removing ununsed import `DataFrame, Panel, Float64Index, Int64Index` but removing them makes everything fail now
@ryankarlos that does seem strange - have you been able to debug that issue locally?
@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 ======================================================
msgpack needs the imports to correctly dessrialize things

you cannot remove them 
Thanks, ok just pushed the imports but what do i do with the linter complaining about unused imports ?
> but what do i do with the linter complaining about unused imports ?

`# noqa:F401` I think

Can you merge master
@jbrockmendel  thanks 
@ryankarlos do we even need this PR any more? I think fixed by the implicit import PR you did earlier
I would rather just boil this PR down to removing the blacklist items if no further changes to imports are required
So OK for me to completely reset changes in this PR as well and only keep mypy.ini changes ?
Yes - the rest of the elements are arguably orthogonal at this point. Can be changed in separate more comprehensive PRs if we desire
Ok thanks - just pushed only mypy changes and reset everything else here and in #25936.  Just waiting for tests to pass.
Thanks @ryankarlos !